yosssi/gmq

Reconnect to server

wolfeidau opened this issue · 2 comments

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.

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

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.