paho.mqtt.android icon indicating copy to clipboard operation
paho.mqtt.android copied to clipboard

Automatic Reconnect Support now??

Open codingWang opened this issue 9 years ago • 10 comments
trafficstars

what can i do in public void connectionLost(Throwable cause) { } method, if it lost connect?

codingWang avatar Aug 29 '16 11:08 codingWang

I'm not 100% sure what you're question is, but if you're asking what the purpose of connectionLost is.. You can use connectionLost to notify your main application / user that the connection has been lost, this might be useful if you want to have different behaviour when there is no connection. Though if you are using Offline buffering, then you could continue to publish messages as normal.

jpwsutton avatar Aug 30 '16 14:08 jpwsutton

haha~thank you so much for your reply, thank you help me add the question label also. I just don't know what can i do in this method@Override public void connectionLost(Threwable cause){// how to reconnect} after the connection losted.

codingWang avatar Sep 03 '16 01:09 codingWang

Assuming that you have enabled the automatic reconnect functionality in the MqttConnectOptions:

MqttConnectOptions mqttConnectOptions = new MqttConnectOptions();
mqttConnectOptions.setAutomaticReconnect(true);

Then you don't have to do anything, the client will attempt to reconnect for you, the connectionLost callback is just there so that you can notify the application / user that the connection was lost, you could just leave it empty if you wanted to.

jpwsutton avatar Oct 14 '16 08:10 jpwsutton

Seems setAutomaticReconnect(true) doesn't work well based on latest commit. I encountered the problem when there was wifi connection lost and recovery, there was no successful connection anymore. Is there any update for this issue now? Thanks.

ruitobe avatar Nov 16 '17 05:11 ruitobe

@eclipsewebmaster Any update since Nov 16, 2017?

paynemiller92 avatar May 04 '18 17:05 paynemiller92

@eclipsewebmaster Any update?

aliab avatar Jun 10 '18 11:06 aliab

+1

km3 avatar Mar 20 '19 05:03 km3

+1

TimmyOl avatar Aug 21 '19 17:08 TimmyOl

setAutomaticReconnect(true) doesn't work

Morteza-Rastgoo avatar Dec 15 '19 12:12 Morteza-Rastgoo

Any plans on fixing a bug 4 Year old bug? :grin:

kalkin avatar Dec 14 '20 11:12 kalkin