yosssi / gmq

Pure Go MQTT Client
MIT License
345 stars 46 forks source link

Reconnect to server #1

Open wolfeidau opened 9 years ago

wolfeidau commented 9 years ago

Just wanted to get your thoughts on the best way to reconnect to an MQTT server using your library.

I noted you have a "handler" for disconnect and wanted to know if you had tested using that to initiate a reconnect?

I am just doing some testing this with this library and at the moment that is the only question.

iambudi commented 6 years ago

Any update about this @wolfeidau, you might want to share on handling the reconnection.

iambudi commented 6 years ago

I could catch the disconnect of message broker in the error handler

client.New(&client.Options{
        // OnDisconnect handler
        ErrorHandler: func(err error) {
            if err.Error() == "EOF" { }

The wierd thing is when i auto reconnect to broker and the target clientID is connected, it works fine, when offline and target ClientID online, the message not submitted. It's like the session is cleaned.