adafruit / Adafruit_MQTT_Library

Arduino library for MQTT support
MIT License
573 stars 291 forks source link

Due to check if (client->connected()) Adafruit_MQTT_Client fails to reconnect to server #105

Open dmpolukhin opened 6 years ago

dmpolukhin commented 6 years ago

https://github.com/adafruit/Adafruit_MQTT_Library/blob/974f4b8713a83d01b040a0d23b798d3f2978d990/Adafruit_MQTT_Client.cpp#L39

It seems that it is required to call client->stop() even if there is no active connection before trying to connect again. In my case server closes connection and due to this check re-connect always fails without even trying to send anything to the network. If I remove check and unconditionally call client->stop(), re-connection does happen.