-
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
SpringApplicationShutdownHook hangs in Mqttv5ClientManager stop() if client never was connected #9112
Comments
Sounds reasonable. However I wonder why you have changed |
Hey, thanks for the quick follow-up. I am yet to collect some insights on this, I am tempted to contribute, but my time is limited. |
Right. So, until the fix in done in the Paho client, let's consider to have a workaround as you have suggested:
Looks like all the MQTT channel adapters have to be fixed. Plus their respective |
Well the actual Bug I stumbled upon in the Paho Client seems to be this one: |
So, you mean that condition won't be enough and we may end up with hanging threads in the Paho client in a |
Not sure whether we are starting to look too deep into the rabbit hole... but here goes
Didn't look for MQTTv3. |
Yeah... I see, that doesn't help:
So, this WDYT? Does it worth it to pursue such a workaround to avoid leaks with these never-ending timers in Paho library? |
Fixes: #9112 `Mqttv5ClientManager` hangs in `stop()` if never was connected. The scheduled reconnect timer in the client is never cancelled. * Call `stopReconnectCycle()` on the client via reflection when we disconnect from the client in Spring Integration MQTT components (cherry picked from commit 937da13)
Fixes: #9112 `Mqttv5ClientManager` hangs in `stop()` if never was connected. The scheduled reconnect timer in the client is never cancelled. * Call `stopReconnectCycle()` on the client via reflection when we disconnect from the client in Spring Integration MQTT components (cherry picked from commit 937da13) # Conflicts: # spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/core/Mqttv3ClientManager.java # spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/core/Mqttv5ClientManager.java # spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/inbound/MqttPahoMessageDrivenChannelAdapter.java # spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/outbound/MqttPahoMessageHandler.java
Fixes: spring-projects#9112 `Mqttv5ClientManager` hangs in `stop()` if never was connected. The scheduled reconnect timer in the client is never cancelled. * Call `stopReconnectCycle()` on the client via reflection when we disconnect from the client in Spring Integration MQTT components **Auto-cherry-pick to `6.2.x` & `6.1.x`**
In what version(s) of Spring Integration are you seeing this issue?
spring-integration-mqtt-6.2.4
Describe the bug
Mqttv5ClientManager hangs in stop() if never was connected.
Mqttv3ClientManager may be affected as well.
see https://www.linkedin.com/pulse/mqtt-paho-tomcat-stop-using-shutdownsh-fails-sudhir-ravindramohan/
To Reproduce
Expected behavior
Troubling code
https://github.com/spring-projects/spring-integration/blob/main/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/core/Mqttv5ClientManager.java#L153
and possibly
https://github.com/spring-projects/spring-integration/blob/main/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/core/Mqttv3ClientManager.java#L151
Sample
Replacing the line
by
makes it work in this case. Not sure if that would be the universal solution. Not tested with
Mqttv3ClientManager
.The text was updated successfully, but these errors were encountered: