-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CONNECTION PROBLEMS, restart, or every other restart #1067
Comments
I will look into wm as the cause of this issue, since it is occurring on both platforms |
I already linked it in #979 but just to have it here again. I don't think it's bug in WifiManager but in the SDK: espressif/arduino-esp32#2501 (nevertheless one that the WifiManager can work around) |
BTW I also suspect the router model to be important for this: In my case it's a Fritz!Box 6490. |
I’ve been having issues with both the ESP8266 and the ESP32 using v2.x.x of WiFiManager but notably the problem goes away on v0.1.5 on my ESP8266, so it might be worth having a look at what changed inside the autoConnect function? I agree it’s probably true that WiFi routers also play a part in this, in my case I’m using a Ubiquity nanoHD access point (with two APs, one downstairs, broadcasting on the same SSID). Maybe that has something to do with it? |
I confirm also that OpenMQTTGateway users were complaining about this issue with Ubiquity routers. |
One difference is we used to always disconnect, //trying to fix connection in progress hanging
ETS_UART_INTR_DISABLE();
wifi_station_disconnect();
ETS_UART_INTR_ENABLE(); But that adds 2 second startup time This was removed in dev and made optional // clean connect, always disconnect before connecting
void setCleanConnect(bool enable); // default false I have also encountered issues where waitforconresult timesout and never connects ( which takes forever ) |
A couple things to try that might be causing a race condition. Try adding this delay and log to this function bool WiFiManager::wifiConnectDefault(){
bool ret = false;
DEBUG_WM(F("Connecting to SAVED AP:"),WiFi_SSID(true));
DEBUG_WM(DEBUG_DEV,F("Using Password:"),WiFi_psk(true));
ret = WiFi_enableSTA(true,storeSTAmode);
// add these 2 lines
delay(500); // <-- DELAY
DEBUG_WM(DEBUG_DEV,"Mode after delay: "+getModeString(WiFi.getMode())); // <-- LOG
if(!ret) DEBUG_WM(DEBUG_ERROR,"[ERROR] wifi enableSta failed");
ret = WiFi.begin();
if(!ret) DEBUG_WM(DEBUG_ERROR,"[ERROR] wifi begin failed");
return ret;
} Another thing to try Remove the sta, begin will do this by itself also bool WiFiManager::wifiConnectDefault(){
bool ret = false;
DEBUG_WM(F("Connecting to SAVED AP:"),WiFi_SSID(true));
DEBUG_WM(DEBUG_DEV,F("Using Password:"),WiFi_psk(true));
// ret = WiFi_enableSTA(true,storeSTAmode); // <-- REMOVE
// if(!ret) DEBUG_WM(DEBUG_ERROR,"[ERROR] wifi enableSta failed");
ret = WiFi.begin();
if(!ret) DEBUG_WM(DEBUG_ERROR,"[ERROR] wifi begin failed");
return ret; Also time how long waitforconnectresult takes, I have been meaning to add some debugging there for timing it. Does it take long when it fails? |
I have the same issue. Sometimes, totally not reproducible for me (I'm sorry), I even get a crash which seems to be related to this. This happens now as long as I erase the flash and flash the image again.
|
I have been looking into this issue here And made a PR here for workaround via autoreconnect bugfix I also have an open issue with IDF against the actual cause under review |
MY PR was merged, but if you need a solution without a patch I added a test solution to wm, hardcoded, no setter. I can add a define or setter if its useful bool _aggresiveReconn = false; // use an agrressive reconnect strategy, WILL delay conxs
// on some conn failure modes will add delays and many retries to work around esp and ap bugs, ie, anti de-auth protections This adds esp32 event handler for auth fail, and bumps reconnects up and adds delays, I have connect everytime, and my conx time goes to 5s unfortunately until this issue is also fixed in IDF that is what we have.. I have not worked on this issue or tested if it exists in esp8266, I will check that next |
Theres seems to be 2 conditions here with different failures, this one for reauth timeout/retry there is also a 4 way handshake timeout or assoc failure which is possibly a different issue |
is there a workaround for this one? I tried the _aggressiveReconn = true fix and it connects but gives me an IP = 0.0.0.0 |
Hmm it shouldnt do you have logs? |
here's the output from the serial port: mounting FS... |
hmm, that is odd, I may have seen this reported elsewhere, or as a different bug... |
What eps lib version , might want to try updating it , i think I recall a bug like this, ill try to test later |
I updated the ESP core version, it seems that it fixed it... |
Yeah I couldn't find the issue, but i specifically recall seeing a IDF bug with failing to set ip |
I'm still experiencing this issue with ESP core version 3.0.2 (via arduino board manager) on an ESP-12E Is there a different combination of core and library versions where this works? |
Can you provide logs with esp debugging on ? The esp core should be retrying these connections itself now. |
Also seeing this on ESP32 (ESP8266 works fine with same code and on latest WiFiManager commit) - AP mode works, I can choose a network. The saved credentials are then tried but no IP is received and the log says:
After the last retry, is also shows these lines:
I've tried this on multiple devices - some very rare times it did connect but pretty much all of the time it does not. |
Ok this is a slightly different issue, have you tried the aggressive recon mod above? |
It's already included by default, but also tried setting it to false |
oh yeah lol |
Hm... While messing around trying to get debug output to work, i discovered that the ESP module is an ESP-12 and not an ESP-12E .. changed this and the issue seems to have vanished... (never got debug output to work) |
There has been several issues with problems with wifi not connecting. But after restarts it works.
Or every other restart it fails
Sometimes there are errors like wrong password, or ap not found
This issue is for investigating this to find some common issue.
I suspect it is a race condition or router issue with certain SDKs etc. It could also be a simple bug like autoconnect is connecting while esp is auto-connecting and it hangs. Or set sta is not returning fast enough and is asynchronous, there has been proof of this and issues by me created in esp libs.
The text was updated successfully, but these errors were encountered: