async-mqtt-client
async-mqtt-client copied to clipboard
Program gets caught in reconnection loop of death
I'm currently playing with the example code on an ESP32. It works fine at first, but after some time the program gets caught in a loop:
Connecting to MQTT... Connected to MQTT. Session present: 0 Connecting to Wi-Fi... Disconnected from MQTT. [WiFi-event] event: 5 WiFi lost connection [WiFi-event] event: 4 [WiFi-event] event: 7 WiFi connected IP address: 192.168.178.56 Connecting to MQTT... Connected to MQTT. Session present: 0 Connecting to Wi-Fi... Disconnected from MQTT. [WiFi-event] event: 5 WiFi lost connection [WiFi-event] event: 4 [WiFi-event] event: 7 WiFi connected IP address: 192.168.178.56 Connecting to MQTT... Connected to MQTT. Session present: 0 ...
This happens reliably after some minutes.
is there any fix on this ? i have to reboot my router or disable WiFi then enable again for 1-2 seconds
Please try the develop branch
Please try the develop branch
same issue with dev branch in my case once OTA is done (arduino ota) it just loop in WiFi & Mqtt connect
disabling WiFi on router only helps me
Strange. I use async-mqtt-client as a part of the homie framework for years now and this hasn't happened to me yet. I also have some ESP projects that don't use homie, but async-mqtt-client, e.g. this: https://github.com/luebbe/WordClock. It also uses Arduino OTA and up to now it has always rebooted and reconected after an OTA update. Not exactly a minimal example, but maybe if you compare how you setup everything to how I do it helps you to find something. But I'm using ESP8266 exclusively, The ESP32 is a different beast.
It really needs a WiFi.disconnect() in the case SYSTEM_EVENT_STA_DISCONNECTED
block otherwise it continually disconnects and reconnects after a disconnect.
It really needs a WiFi.disconnect() in the
case SYSTEM_EVENT_STA_DISCONNECTED
block otherwise it continually disconnects and reconnects after a disconnect.
This seems to have solved this problem for me on ESP32