Closed jokarl closed 5 years ago
I rebuilt iot-device-client
locally with updated paho dependency:
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.1</version>
</dependency>
It now only creates 4 threads upon first calling open
, calling closeNow
and then open
again and there are still 4 threads:
Thread [MQTT Rec: leafdevice] (Running)
Thread [MQTT Snd: leafdevice] (Running)
Thread [MQTT Call: leafdevice] (Running)
Thread [MQTT Ping: leafdevice] (Running)
Would you like me to issue a pull request?
I can create the PR for this. I'm glad to see Paho has fixed this issue as it has been around for a while. Thanks for bringing it to our attention.
No problem, glad to help!
Just to update this issue, we have attempted to upgrade our paho dependency to resolve this threading issue, but we are encountering regressions around mqtt_ws. We are still investigating the cause of these, and we'll try to keep this thread updated with our findings.
Sorry for the intermittent updates, but to keep this thread up to date, Paho version 1.2.1 did introduce a regression on MQTT_WS connections, so until that issue is resolved, we cannot upgrade to fix this thread leak. I have opened an issue on Paho's issues page about this regression here.
No worries, we've worked around it the meantime. I understand it's out of your control.
A member of the MQTT Paho team is actively looking into the bug in Paho 1.2.1 that was preventing us from upgrading our dependency. We plan on updating and releasing our SDK as soon as that new Paho version becomes available. That new version of Paho should resolve this issue.
Just an update on this, the 1.2.2 release of Paho is imminent as per https://github.com/eclipse/paho.mqtt.java/issues/679#issuecomment-531194567
We are working to upgrade our Paho dependency now that they have released version 1.2.2. Thankfully, it appears that this leaked thread bug is not present in 1.2.2 so once we upgrade our dependency, I will do a release of this SDK and close this issue.
As of this release, the device client and deps will now use Paho version 1.2.2. This newest version of Paho fixed this issue, so I'm closing this issue.
@hochas, @kartben, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey
OS and version used: Ubuntu 18.04.2 LTS
Java runtime used: openjdk version "11.0.1" 2018-10-16 OpenJDK Runtime Environment (build 11.0.1+13-Ubuntu-3ubuntu118.04ppa1) OpenJDK 64-Bit Server VM (build 11.0.1+13-Ubuntu-3ubuntu118.04ppa1, mixed mode, sharing)
SDK version used: 1.15.0
Description of the issue:
Calling closeNow() leaves threads open. On startup, when connecting and calling
open
for the first time:This result also seems weird, why are there duplicate
Call
,Rec
andSnd
threads? We are using a modified version of this sample to connect devices. We are only callingopen
once from our application code.I leave the application running, but I call
client.closeNow();
and reconnect the device. The stack now looks like this:Notice that there is one new instance of
Call
,Rec
andSnd
each, as well as a duplicate ofDisc
. Still only a singlePing
thread.Code sample exhibiting the issue:
141 discusses the same issue. It seems the related Paho issue has been resolved, but there have been no new releases of the SDK since this fix.