Skip to content

Reconnection / retry error with Paho MQTT 1.2 leads to ever increasing thread usage #2471

Closed
@michael-simons

Description

@michael-simons

As a follow up to my tweet.

Find attached a simple Spring Integration MQTT application (mqtt-paho-client-threading-bug.zip). It's a Spring Boot app, just run

./mvnw clean spring-boot:run

You'll find the app trying to reach a MQTT broker on tcp://localhost:45678 (I chose this port to make sure there is no broker answering).

The app will fail, print the MQTT Paho exception and continue.

I'll added a scheduled task that prints the number of live threads. As you see they'll increse by 2 threads after each failed connection retry.

This happens during startup as well as during runtime, for example if the broker goes away in between.

A downgrade to Paho 1.1.1 as suggested in eclipse-paho/paho.mqtt.java#402 respectivly SebaDro/SOS@8b9f09e helps, for example like this:

    <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-mqtt</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.eclipse.paho</groupId>
                    <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.eclipse.paho</groupId>
            <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
            <version>1.1.1</version>
            <scope>compile</scope>
        </dependency>

With Paho 1.1.1 the number of threads stays constant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions