monstrenyatko / ArduinoMqtt

MQTT client for Arduino
MIT License
72 stars 13 forks source link

mqtt->isConnected() not working when disconnect to server #1

Closed tarzan115 closed 7 years ago

tarzan115 commented 7 years ago

I am using Arduino ESP8266 to connect Broker, but when client disconnect to Broker I check by code mqtt->isConnected() and it not realize disconnect even. I write my code by example and change buffer to 550 and MessageHandlersImpl to 5.

thank you so much for your library.

monstrenyatko commented 7 years ago

@tarzan115 The network connection is not handled by the library. Library controls only MQTT layer of the communication. It uses only read and write methods from the MqttClient::Network object that you need to provide.

The MqttClient can detect the disconnection only whendisconnect is called manually or something goes wrong:

In your case I see two options:

tarzan115 commented 7 years ago

thank you so much for your answer. I had test only TCP, it disconnect every 30 senconds. I am checking my server.

thanks.

monstrenyatko commented 7 years ago

@tarzan115 I have found and fixed the issue with keepalive implementation (See 1fd305fca857bf2dbbd1e4a85ecb2cdc2435954d).

Created the improvement ticket #2 to be able to provide network connection status to the library to detect TCP disconnect almost immediately.

tarzan115 commented 7 years ago

thank you for this :D