async-mqtt-client icon indicating copy to clipboard operation
async-mqtt-client copied to clipboard

Program gets caught in reconnection loop of death

Open BorisBrock opened this issue 3 years ago • 6 comments

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.

BorisBrock avatar Nov 05 '20 09:11 BorisBrock

is there any fix on this ? i have to reboot my router or disable WiFi then enable again for 1-2 seconds

cyber-junkie9 avatar Jun 01 '21 08:06 cyber-junkie9

Please try the develop branch

luebbe avatar Jun 01 '21 09:06 luebbe

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

cyber-junkie9 avatar Jun 02 '21 07:06 cyber-junkie9

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.

luebbe avatar Jun 02 '21 08:06 luebbe

It really needs a WiFi.disconnect() in the case SYSTEM_EVENT_STA_DISCONNECTED block otherwise it continually disconnects and reconnects after a disconnect.

nottledim avatar Jun 11 '22 16:06 nottledim

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

olie-o avatar Jan 02 '23 06:01 olie-o