fusesource / mqtt-client

A Java MQTT Client
http://mqtt-client.fusesource.org/
Apache License 2.0
1.27k stars 369 forks source link

how to reconnect when mqtt server restart? #91

Open ashishvaghasiya-digicorp opened 7 years ago

ashishvaghasiya-digicorp commented 7 years ago

After restarting mqtt server client not getting the message. how to handle this.

Doogiemuc commented 6 years ago

I have the same question. After the MQTT server restarts, how does the client recognize that. I'd assume, that the client would see that there are no more heartbeat messages any more (becuase the connection dropped). But what exactly does the mqtt-client lib then do? Is there any callback that I can subscribe to?

ashishvaghasiya commented 6 years ago

@Doogiemuc

i have solution of this problem.

in "onConnectionLost" event you get connection lost information on client side

aviappusingh commented 4 years ago

Hi , where you got "onConnectionLost" event in MQTT client side ? We are facing same issue .Whenever a broker is restarted ,in shared subscription some topics we get and some not .sometimes we dont get any messages .

Thus one of the solution is to restart complete client process once broker restarts .but to know that ,we need to implement something similar and please note we dont get any disconnect /error message even if broker restarts.