-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reconnection / retry error with Paho MQTT 1.2 leads to ever increasing thread usage #2471
Comments
Unfortunately I cannot go back to 1.1.1 as then my client connections become unstable. As a matter of fact, I do not receive any further messages after the initial topic report. Paho 1.2.0 fixed this strange behavior. Somehow we need to fix the thread shutdown issue. |
They really need to fix the client; we can look at closing/creating a new client each time, but that just seems wrong. |
Looking into the Paho Code, I see that the MqttAsyncClient can be setup to use an explicitly given ThreadPool like so:
Do you see a chance to explicitly kill this threadpool on app/container shutdown? Neither |
My mistake; it's our bug; we do create a new client on each attempt; we just don't clean up the old one. |
I join the "mea culpa" chant: My mistake was the I am now calling the following in a
|
Fixes spring-projects#2471 Call `close()` on the client whenever the connection is lost or can't be established, to release resources in the client. **cherry-pick to 5.0.x, 4.3.x**
I tested your app against the snapshot locally and there is no more leak. Releases that will include this fix are scheduled for next Wednesday. |
Wow, awesome reaction. Thanks a lot! |
Fixes #2471 Call `close()` on the client whenever the connection is lost or can't be established, to release resources in the client. **cherry-pick to 5.0.x, 4.3.x**
Fixes #2471 Call `close()` on the client whenever the connection is lost or can't be established, to release resources in the client. **cherry-pick to 5.0.x, 4.3.x** (cherry picked from commit f9cea64) # Conflicts: # spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/MqttAdapterTests.java
Need similar logic in the outbound adapter. |
Thank you and for reference, the details of what we experienced: https://gitter.im/spring-projects/spring-integration?at=5bbd2483bbdc0b250512e7ce
|
Resolves #2471 # Conflicts: # spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/MqttAdapterTests.java
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
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:
With Paho 1.1.1 the number of threads stays constant.
The text was updated successfully, but these errors were encountered: