OpenMQTTGateway icon indicating copy to clipboard operation
OpenMQTTGateway copied to clipboard

Implement failure_number_ntwk for reconnects

Open tablatronix opened this issue 1 year ago • 7 comments

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.

tablatronix avatar Sep 19 '23 02:09 tablatronix

There is already a counter used when having build time wifi credentials: failure_number_ntwk we could use it when Wifi Manager is used

1technophile avatar Sep 19 '23 19:09 1technophile

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.

MichielioZ avatar Oct 14 '23 19:10 MichielioZ

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

tablatronix avatar Oct 15 '23 03:10 tablatronix

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar Jan 14 '24 00:01 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jan 29 '24 00:01 github-actions[bot]

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

image

Gonna recompile and try again in case anything updated

tablatronix avatar Jan 30 '24 04:01 tablatronix

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar Apr 30 '24 00:04 github-actions[bot]

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar Jul 30 '24 00:07 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Aug 13 '24 00:08 github-actions[bot]