OpenMQTTGateway
OpenMQTTGateway copied to clipboard
Implement failure_number_ntwk for reconnects
I noticed if wifi reconnect fails, nothing happens, we just get stuck here. Reimplement counter and restart to avoid this. And perhaps make sure reboot looping is avoided, maybe a min uptime before it kicks in.. hmmmm
} else { // disconnected from network
connected = false;
Log.warning(F("Network disconnected:" CR));
ErrorIndicatorON();
delay(2000); // add a delay to avoid ESP32 crash and reset
ErrorIndicatorOFF();
delay(2000);
#if defined(ESP8266) || defined(ESP32) && !defined(ESP32_ETHERNET)
# ifdef ESP32 // If used with ESP8266 this method prevent the reconnection
WiFi.reconnect();
Unrelated: I am investigating the cause of my reconnects not working (ap_not_found) and think it is actually memory related (leak). There are also some ESP bugs that cause this in some IDF versions. But regardless of the reason, this would be a good failsafe to add.
There is already a counter used when having build time wifi credentials: failure_number_ntwk
we could use it when Wifi Manager is used
On a related note: on first boot, the AP requests wifi and mqtt configuration. As I just wanted to test and have no mqtt server setup at the moment, I only entered correct wifi credentials. This results in an infinite loop of trying to connect to an mqtt server and rebooting (if I didn't have the serial console open I wouldn't have noticed). Maybe store wifi credentials and mqtt credentials seperately ? I know with Wifi Manager it will return to AP mode if wifi fails, but in the case of wrong mqtt credentials I would suspect it still boots but just doesn't connect after some retries.
Good point there is a seperate counter for wifi and mqtt so something could be done there.
i have been testing a fix for this for a while and it seems to be working well. Will pr it when i can test a few more issues
This issue is stale because it has been open for 90 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
I have not forgotten about this, I have been testing this and logging data. Unfortunately i have not figured out what causes this, but with the restart my devices stay online at least. Not sure its the best solution, but with no other ideas or info , I have no idea why reconnect just stops working. probably an sdk phy bug. I thought it was a memory leak, but this specific device does not have a leak and still restarts, so its something else.
I also do not see this with my other devices or tasmota, shrug
Gonna recompile and try again in case anything updated
This issue is stale because it has been open for 90 days with no activity.
This issue is stale because it has been open for 90 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.