[GH-ISSUE #1710] WiFi connection stuck in an infinite retry #1451

Closed
opened 2026-02-28 01:30:07 +03:00 by kerem · 6 comments
Owner

Originally created by @rusty-labs on GitHub (Feb 14, 2024).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1710

Basic Infos

Hardware

WiFimanager Branch/Release: Master

Esp8266/Esp32:

Hardware: Heltec wifi-lora-32-v3

Core Version: 2.4.0, staging

Description

Steps to reproduce

  • Connect to AP
  • Input incorrect password for wifi
  • Save settings and restart ESP32

As a result program is stuck in an infinite reconnection loop

Problem can be solved by changing

_aggresiveReconn = false

Settings in IDE

Module: wifi-lora-32-v3

Sketch

WiFi.mode(WIFI_STA);

        wm.addParameter(&paramMqttServer);
        wm.addParameter(&paramMqttPort);
        wm.addParameter(&paramMqttUser);
        wm.addParameter(&paramMqttPassword);

        std::vector<const char *> wm_menu = {"wifi", "exit"};
        wm.setShowInfoUpdate(false);
        wm.setShowInfoErase(false);
        wm.setMenu(wm_menu);

        bool res = wm.autoConnect(_SSID);

Debug Messages

*wm:Connect Wifi, ATTEMPT # 2 of 13
*wm:Connecting to SAVED AP: xxx
E (30510) wifi:sta is connecting, return error
[ 30074][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007
*wm:Connect Wifi, ATTEMPT # 3 of 25
*wm:Connecting to SAVED AP: xxx
E (42016) wifi:sta is connecting, return error
[ 41580][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007
*wm:Connect Wifi, ATTEMPT # 4 of 37
*wm:Connecting to SAVED AP: xxx
E (53522) wifi:sta is connecting, return error
[ 53086][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007
*wm:Connect Wifi, ATTEMPT # 5 of 49
*wm:Connecting to SAVED AP: xxx
E (65028) wifi:sta is connecting, return error
[ 64592][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007
*wm:Connect Wifi, ATTEMPT # 6 of 57
*wm:Connecting to SAVED AP: xxx
E (76534) wifi:sta is connecting, return error
[ 76098][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007
*wm:Connect Wifi, ATTEMPT # 7 of 69
Originally created by @rusty-labs on GitHub (Feb 14, 2024). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1710 ### Basic Infos #### Hardware WiFimanager Branch/Release: Master Esp8266/Esp32: Hardware: Heltec wifi-lora-32-v3 Core Version: 2.4.0, staging ### Description Steps to reproduce - Connect to AP - Input incorrect password for wifi - Save settings and restart ESP32 As a result program is stuck in an infinite reconnection loop Problem can be solved by changing `_aggresiveReconn = false` ### Settings in IDE Module: wifi-lora-32-v3 ### Sketch ```cpp WiFi.mode(WIFI_STA); wm.addParameter(&paramMqttServer); wm.addParameter(&paramMqttPort); wm.addParameter(&paramMqttUser); wm.addParameter(&paramMqttPassword); std::vector<const char *> wm_menu = {"wifi", "exit"}; wm.setShowInfoUpdate(false); wm.setShowInfoErase(false); wm.setMenu(wm_menu); bool res = wm.autoConnect(_SSID); ``` ### Debug Messages ``` *wm:Connect Wifi, ATTEMPT # 2 of 13 *wm:Connecting to SAVED AP: xxx E (30510) wifi:sta is connecting, return error [ 30074][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007 *wm:Connect Wifi, ATTEMPT # 3 of 25 *wm:Connecting to SAVED AP: xxx E (42016) wifi:sta is connecting, return error [ 41580][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007 *wm:Connect Wifi, ATTEMPT # 4 of 37 *wm:Connecting to SAVED AP: xxx E (53522) wifi:sta is connecting, return error [ 53086][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007 *wm:Connect Wifi, ATTEMPT # 5 of 49 *wm:Connecting to SAVED AP: xxx E (65028) wifi:sta is connecting, return error [ 64592][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007 *wm:Connect Wifi, ATTEMPT # 6 of 57 *wm:Connecting to SAVED AP: xxx E (76534) wifi:sta is connecting, return error [ 76098][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007 *wm:Connect Wifi, ATTEMPT # 7 of 69 ```
kerem 2026-02-28 01:30:07 +03:00
Author
Owner

@tablatronix commented on GitHub (Feb 14, 2024):

Hmm how tf is _connectretries increasing? Lol what in the world

<!-- gh-comment-id:1944761760 --> @tablatronix commented on GitHub (Feb 14, 2024): Hmm how tf is _connectretries increasing? Lol what in the world
Author
Owner

@rusty-labs commented on GitHub (Feb 14, 2024):

There is only one reason

if (info.wifi_sta_disconnected.reason == WIFI_REASON_ASSOC_FAIL)
    {
      if (_aggresiveReconn)
        _connectRetries += 4;
      DEBUG_WM(DEBUG_VERBOSE, F("[EVENT] WIFI_REASON: AUTH FAIL"));
    }

_connectretries is increased exactly by 12, meaning that the code above is being called 3 times

<!-- gh-comment-id:1944775135 --> @rusty-labs commented on GitHub (Feb 14, 2024): There is only one reason ``` if (info.wifi_sta_disconnected.reason == WIFI_REASON_ASSOC_FAIL) { if (_aggresiveReconn) _connectRetries += 4; DEBUG_WM(DEBUG_VERBOSE, F("[EVENT] WIFI_REASON: AUTH FAIL")); } ``` _connectretries is increased exactly by 12, meaning that the code above is being called 3 times
Author
Owner

@tablatronix commented on GitHub (Feb 15, 2024):

What line is that code? I missed it

<!-- gh-comment-id:1945257662 --> @tablatronix commented on GitHub (Feb 15, 2024): What line is that code? I missed it
Author
Owner

@rusty-labs commented on GitHub (Feb 15, 2024):

github.com/tzapu/WiFiManager@0d84861270/WiFiManager.cpp (L3833)

<!-- gh-comment-id:1945280430 --> @rusty-labs commented on GitHub (Feb 15, 2024): https://github.com/tzapu/WiFiManager/blob/0d84861270c3cd64f72a4eaf34443ee580d2547e/WiFiManager.cpp#L3833
Author
Owner

@tablatronix commented on GitHub (Feb 15, 2024):

I am so dumb. Lol usually this error only happens once I guess this should only be set one time

<!-- gh-comment-id:1945294271 --> @tablatronix commented on GitHub (Feb 15, 2024): I am so dumb. Lol usually this error only happens once I guess this should only be set one time
Author
Owner

@rusty-labs commented on GitHub (Feb 15, 2024):

There is a typo
if(_aggresiveReconn & _connectRetries<4)

<!-- gh-comment-id:1945420901 --> @rusty-labs commented on GitHub (Feb 15, 2024): There is a typo `if(_aggresiveReconn & _connectRetries<4)`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1451
No description provided.