Open Laxilef opened 11 months ago
Code above does not look like the linked WiFiManager .ino file though. You sure it is Core and / or SDK leaking something and not your app / WiFiManager / some other lib?
STA disconnect: 202
Name would suggest it could not authenticate with the given passphrase and / or auth settings
WiFi.begin();
begin() without parameters usually means SSID & passphrase were already set, either in persistent mode when those are read from flash or without one where those are managed in RAM. Invalid credentials are the most likely explanation for the error above.
Code above does not look like the linked WiFiManager .ino file though. You sure it is Core and / or SDK leaking something and not your app / WiFiManager / some other lib?
I am using this code in my project OTGateway. I didn’t show the entire code of the project, because it wouldn’t be interesting to you, but part of the code for working with Wifi can be viewed here. I tried removing other code and working only with Wifi, the behavior is the same. At least 2 users reported me about this behavior and sent me logs. I spent a long time studying other used libraries and did not find any leaks there. It makes me think that the problem is in SDK due to the fact that memory leaks begin strictly after calling the reconnection code to Wifi.
It's really strange that I've very rarely been able to reproduce this, meaning it's not permanent. I've been trying to find the reason for more than 2 weeks before creating this issue.
begin() without parameters usually means SSID & passphrase were already set, either in persistent mode when those are read from flash or without one where those are managed in RAM. Invalid credentials are the most likely explanation for the error above.
Hmm. SSID and password are stored in flash memory. However, after a reboot or cold start, the ESP successfully connects to the router. For example, calling WiFi.reconnect()
gave the same result: the ESP did not connect and the memory decreased with each call to this method.
What advanced tests can I run for you to investigate this issue? Could it be hardware problems? Thanks.
Hmm. SSID and password are stored in flash memory. However, after a reboot or cold start, the ESP successfully connects to the router. For example, calling WiFi.reconnect() gave the same result: the ESP did not connect and the memory decreased with each call to this method.
Depends on two SDK settings, WiFi has slightly different names for them (see ESP8266WiFiSTA.cpp for the underlying stuff)
The minimal setup would look something like this, without WiFiManager for right now. Loop then never calls anything related to connection management
void setup() {
// otherwise, Core turns WiFi off. this reverts to 2.x.x and SDK default STATION opmode
enableWiFiAtBootTime();
// so WiFi.begin(..., ...) puts stuff into flash
WiFi.persistent(true);
// note that persistent() does not affect these two, both values always persist between reboots
if (!WiFi.getAutoConnect()) {
WiFi.setAutoConnect(true);
}
if (!WiFi.getAutoReconnect()) {
WiFi.setAutoReconnect(true);
}
// assume connection already happening. call begin to reset credentials
if (WiFi.waitForConnectResult(10000) != WL_CONNECTED) {
WiFi.begin(MY_SSID, MY_PASS);
}
}
I don't see anything suspicious with a simple ping app. Also no difference between SDK versions. 2.2.x and then upgraded to 3.0.5, both seem to work just fine.
Heap slowly goes down from 50968 to 47056, but never lower. Disconnection is either by simply covering the antenna, or iw dev ... station del MAC
kick from the router cli
Hi, @mcspr! Happy New Year and thanks for your reply. I also tried this option, but previously abandoned it because there were complaints that when disconnected from Wifi, the ESP did not reconnect. But I did not call begin when there was no connection, since it is assumed that the connection data is taken from flash.
I am now confused about the situation I described in the first msg. For tests, I’ll try to make the code without all the extra stuff and come back with the results. If you have any ideas why this might be happening, please let me know. Thanks!
Same problem here, but in softAP mode. Randomly disconnects the client and leaks and bunch of memory when trying to reconnect, which ultimately fails.
Basic Infos
Platform
Settings in IDE
Problem Description
On some ESP8266 I am seeing a problem with reconnecting to Wifi. At a random moment in time, the ESP loses its connection to the Wifi and I try to reconnect, but the ESP does not connect. I also tried adding the following code before calling
WiFi.begin()
:But this does not give any result. Eventually the memory runs out and the ESP reboots with an exception. Decoding the stacktrace does not give anything, because all the exceptions are related to the inability to allocate memory. The strange thing is that this does not happen with all ESPs.
I compiled with the flags
-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_PORT=Serial
and saw something strange:After this, the ESP refuses to connect to Wifi. But after a restart (cold start), the connection works correctly.
MCVE Sketch
https://raw.githubusercontent.com/tzapu/WiFiManager/master/examples/NonBlocking/AutoConnectNonBlocking/AutoConnectNonBlocking.ino
Debug Messages