Closed harryd100 closed 8 years ago
Do you disconnect the previous connection (via MQTT_Disconnect) after the connection to the other API is established?
This change dropped the MQTT_Disconnect call which was happening inside MQTT_Connect if the connection was already established. The call was dropped as disconnection itself is a multi-step process:
If the connection is disconnected without waiting for the invocation mqtt_tcpclient_discon_cb, the disconnection callback may be invoked at any point in time. Depending on the current state this may lead to spurious reconnects.
Hi, I'm pretty much use the same code as in the library example, so i don't know what you mean with "Do you disconnect the previous connection (via MQTT_Disconnect) after the connection to the other API is established?". Since removing the "Disconnect before reconnecting" code-change all my devices work flawlessly for weeks now
I guess you're referring to https://github.com/tuanpmt/esp_mqtt/blob/master/user/user_main.c? If that's the case can you try if adding a MQTT_Disconnect(&mqttClient); before the call to MQTT_Connect(&mqttClient) in line 46 mitigates the issue?
I'll try to reproduce this locally in the next couple of days.
Hi, Just tested this new commit and seems to work much better. Roaming between AP's now reconnects the ESP again. Thanks for fixing.
Hi, Since last change "Disconnect before reconnecting" I have an issue when my ESP roams to another AP. Although Wifi comes up and I have an IP address, MQTT is not working anymore. After a reset everything works again. After removing the changes from "Disconnect before reconnecting" it works again, also when the ESP roams to another AP.