Open matsukaz opened 7 years ago
This behaviour is left over from before we implemented the true auto-reconnect functionality in the Java client that then spilled over to the Android Service. I didn't remove the old automatic reconnect functionality so as not to break any clients that were not expecting the old behaviour. I'd like to remove this in a future release though.
I'm glad to hear that! thanks. Hope this behavior will be removed soon 👍
Has this ever been solved? I'm evaluating this library and I'm having problems with reconnecting. I've tried setting autoReconnect to off and managing the reconnection by myself, but I get crashes when calling isConnected
or publish
on a client which I've called disconnect
on before. Simply creating new clients leaves the old ones somewhere in the background, they appear to even want to reconnect when I've called close
on then. I'm very, very confused about this library.
Library works perfect for me, except it's reconnection behavior.
I assumed that paho.mqtt.android only reconnects if
autoReconnect
is set to true, but actually it also reconnects if the connection is disconnected and alsocleanSession
is set to false.https://github.com/eclipse/paho.mqtt.android/blob/develop/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/MqttConnection.java#L1055
It seems to me that
cleanSession
is only used for session persistence, such asand reconnection should only occurs if
autoReconnect
is set to true. Objective-C MQTT Client Framework is working just like that.I've tested to remove the code in my repository and worked just like I supposed.
https://github.com/matsukaz/paho.mqtt.android/commit/a1e8ac23f93d62c5474283bd46445b206f63c13e
What do you think about this ?