-
Notifications
You must be signed in to change notification settings - Fork 7.6k
WiFi connection unstable after updating to 2.0.X #6654
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
Comments
@PilnyTomas, PTAL |
Hi, I've tested your sketch on ESP32 with the PCB antenna (I don't have one with the external antenna) |
I don't believe the timeout is really set with those flags in the recv. They need to adapte the LWIP library, so we could make it work. The library just don't wait. So why setting a timeout... |
I tested this with one board with a PCB antenna and one with an external one. My hypothesis based on the EMS-ESP32 issue is that I just have a router that is compatible with the old version, but not the new version, however I did not yet test it with a different one. However even if it is something that only occurs with some routers, considering how quickly someone else reported it on the EMS repo I believe its still worth trying to fix it. |
The ESP-IDF WiFi library comes as a blob to us (both Arduino and ESP-IDF). In order to be able to forward the issue to our radio team, we need first to have a proper information of the reason. Given that we can not reproduce it, chances are that they will not be able either (else they would have not caused a regression). Good luck with testing. See if you can change settings on your router and will they also change the connection time. |
Unfortunately it doesn't have that many settings that I could see changing this, thats why I want to try it with different hardware, like a RPi or my phone. I do also intend to test this with the ESP-IDF eventually, but since I don't have an ESP-IDF workspace set up yet, and will probably take a while to get used to it enough to test this, that might be quite a while in the future. |
Use a ping, you will see. Its hard to test it. Therefore you need a stream with a high bitrate. |
I'm sorry, but I don't quite get what this means. |
LWIP... You can't connect to the wifi without it. |
I am aware LWIP is used for network stuff internally, however I do not have the knowledge to mess with it, nor much on how it works unfortunately. |
Me ether, we have to find someone with a good knowledge of Linux to solve this. We see some packages come in slow. The source of the issue is still undefined. The problem is that there is no way around with the current version of the LWIP. |
Sorry for taking so long, but I finally tested this with a hotspot on my phone. |
I played around a bit with my router settings, not expecting anything to help since there wasn't a setting that seemed related, and I can no longer reproduce this. I see a decent chance that this issue will just magically re-appear after waiting for a night, like most of my WiFi issues so far, but atm there is nothing I can think of to reproduce this. The ESP also seems to be fully connected and ready 130-1600ms after startup, which is faster than I can remember it ever being in the past. |
I just noticed I didn't make this clear in my last messages: |
Is it possible that you have a small pool of addresses in your router's DHCP config and they get filled by the computers and devices you have at home? One way to check this is if you get it to start failing again to restart the router and if it get's "fixed" for some time, that could be one clue. |
The router is set to give out dhcp addresses from 192.168.2.100 to 192.168.2.200, and the highest I can remember seeing was 192.168.2.156 or something similar. Another thing is, it didn't work after a restart, it worked after changing the WiFi band. The router can use b/g, b/g/n, or a/n. |
I just checked, and the issue is back without me changing anything. |
It seems to be about the DHCP service from the AP Router that may reassign ESP STA IP to some other STA in the network... Try this: // call back function when IP is Lost by Station -- needs to reconnect to AP
void WiFiStationLostIP(arduino_event_id_t event)
{
log_d("Enter into LOST IP Event Call Back...");
while (! WiFi.reconnect()) {
log_d("Trying to Reconnect due to STA__LOST_IP...");
delay(500); // wait a bit for the necessary processing
}
}
void setup() {
...
// Set a callback function when the event STA_LOST_IP happens
WiFi.onEvent(WiFiStationLostIP, ARDUINO_EVENT_WIFI_STA_LOST_IP);
...
} |
When I originally tested things for this issue I had a lot of WiFi callbacks that just print debug info, one of them being LOST_IP. The test.sh file I am using here is the connection check script I posted in the original issue. Click to expand
This time the initial connection works instantly, which it usually doesn't, but it still fails after a while without calling LOST IP and then reconnects and works again. |
How far is the ESP32 from the AP Router? It seems like the ESP gets "lost in the space" for a while... |
Is there some sort of Maybe a nice test would be adding a PING call in the sketch loop to check the connection to the AP Router IP address. |
I think that ESP32 considers that it has being with no connection to the AP Router for time enough to consider it has disconnected. But there is a question.... if you run this same example with 1.0.6, evething works perfectly well? |
I tested that a few times when I initially made this issue, and I tested it again just now. |
Oh btw I wont be able to test the version 2.0.X things for a while, because my PC died today. |
The ping results are the same with 1.0.6? |
I can get you a full combined log tomorrow, I assumed that wasn't relevant since its fully working. |
That 1.0.6 log would help in comparing both version results. |
I just ran the test again with 1.0.6. Click to Show
While the ping still fluctuates it seems like the RSSI is consitently higher. |
The RSSI questionable... When I did some tests I found out that when I was close I had a higher RSSI, than I was far from the transmitter (ps: I only print it at bootup). And a longer antenna didn't improve the RSSI. I installed an app on my phone to scan RSSI arround me and the fluctuate too. I m curious... can you set a delay between the pings you send from the server, big engough to see if it has infuence on that. Let say 2second between each ping. I'm curious if it stablizes. |
The RSSI is signal strength, its supposed to be higher when you're closer.
A lot more things than just the antenna length matter for the RSSI.
Well, yeah, RF stuff always fluctuates a bit due to environmental factors.
What? Currently my sketch pings once every 3 seconds. |
Thanks @ToMe25 for the 1.0.6 log. It is really very different from the 2.0.0+ log in terms of ping success.
Yes, I agree that this RSSI difference is something that may explain the 2.0.0+ issue with connection stability, but really not conclusive. |
Having the same behaviour on my side - after upgrading to 2.0.5 Wifi is completely unstable. |
I have the same issue on ESP32 (sparkfun ESP32 Thing) Testing with Window10 running Bluestack5 Android emulator running pfodApp Power cycle the sparkfun ESP32 Thing, Second and third connections usually send more outgoing packets before dropping one. After about 3 re-connections the connection appears to be stable until the ESP32 is power cycled again. Attached is the wireshark capture (zipped because github won't upload .pcapng) Also attached is the Serial monitor output of the received / sent msgs The ESP32 send msgs are buffered and the written using Edit 2 -- Rolled back to ESP32 V2.0.0 works fine on that version |
I having troubles too when my shetch gets bigger. A special when more small packages are send and received after eachother. I have two clients in that shetch one with a high volume of data (receiving) and the other one that is sending and receiving small packages. It's hard to tell what the exact problem is. But if I put the Verbose log on I always get ASSOC_LEAVE. I think we need to make a simple shetch that is sending and receiving between two esps and where the load and the time between can be adjusted and one client can be added afterwards. The problem is I don't have time for a couple of weeks. |
I had problems with ESP32 connections using V2.0.0 so have rolled back to V1.0.6 now |
That's OK if you don't use tsl. |
pfodApp uses a secure hash appended to each message to provide wifi security against modification (not obscurity) so not a problem going back to V1.0.6 for pfodApp connections |
It seems this issue needs to be tested against 3.x version. Please, re-open this with an updated report if problem persists. |
Board
ESP32DevkitCVE/IE
Device Description
The devkit with an external antenna connector(CVIE) an external antenna is connected, in the case of the one with internal antenna nothing is connected besides a PC using an USB-A to USB-Micro-B cable.
Hardware Configuration
Nothing connected.
Version
latest master (checkout manually)
IDE Name
PlatformIO - Eclipse
Operating System
Ubuntu 20.04
Flash frequency
40MHz
PSRAM enabled
no
Upload speed
921600
Description
After updating a sketch from 1.0.6 to 2.0.2 I noticed that the WiFi in STA mode doesn't get an IP until it times out and reconnects.
This can already take a few minutes, and is the case even tho the first WiFi method called in that sketch is
WiFi.disconnect(true);
.After finally connecting WiFi works for a few minutes, before silently stopping(No log output even with
CORE_DEBUG_LEVEL
set to 5).After not working for a few minutes it causes a disconnect event, on which my sketch would then reconnect.
This actually works, and doesn't take a few minutes.
After some useless debugging I then tried to find a minimal sketch to reproduce this.
My end result was pretty much just a web server, but I will post this sketch below.
I then tried the
SimpleWiFiServer
example. which seems to have the same issues, except it didn't seem to ever reconnect.Restarting the ESP did not seem to change anything at all.
This might be related to #4980
In the log of my custom sketch below I used a bash script to request the content of the web server every 3 seconds.
As far as I know that is the only thing that interacted with the ESP during the time of the test.
The log doesn't seem to change much even without the script, however I wanted to know when it stops working.
Here the script:
Sketch
Debug Message
SimpleWiFiServer log:
Click here to show
Custom Sketch(posted above) Debug Log:
Click here to show
Other Steps to Reproduce
It works correctly with version 1.0.6, if the event names are changed to account for the version change.
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: