-
Notifications
You must be signed in to change notification settings - Fork 13.3k
WiFi client hangs on reconnect/wifi lost #231
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
Why it at least does not reboots? It is very bad behavior... |
check you hardware (GPIO) setup.
|
My usb ttl adaptor don't DTR and RST pin GPIO0 button to GND and manuel firmware mode resetting push button |
for normal boot GPIO0 need to be High. GPIO0 shut only be low (GND) if you want to upload new software in all other cases it need an pullup |
I have the same problem. The code I'm showing below wokr's great until I do not reboot router. I have tried many ways to jump over this issiue, like rebooting the ESP8266, but no luck so far. :( Any ideas?
Complete code:
|
I have similar problem, when PubSubClient was publishing message and I unplug wifi AP from power, it caused a garbage line in serial monitor and ESP restart itself... Is there any way to protect itself from reboots? I tried something like this, but it did not help... if(WiFi.status() == WL_CONNECTED){ |
i guess there are alot of people with this problem, I had already launched a report about it in april. didn't get a response until today. stated wl_connected only checks to see if you have an IP address that is dynamically assigned, didn't explain anything further. my esp keeps on boot cycling until an IP address is given either static or dynamic don't matter. but is non functional until it has one, doesn't make this piece a viable micro controller because of this problem. Oh and one other thing, take that 20 dollar wal wart (ac to dc adapter usually has the switch on the side to change voltage) and throw it the hell away, 99% of those things are garbage, put them under load and the voltage drops a lot. and if you really insist on using one, put a big cap on it, i needed 2 X 1000uf to smooth out the bounce, lot of them have AC bounce really bad. measure it with nothing connected and everything is fine. junk, for purposes of benching and uploading, a computer PSU has 12V 5V and... 3.3V. 15 to 20 bucks, and what is really nice if ya short something (been up to long???) the PSU drops right out. if you need instruction on how to fire one up without being in a computer msg me, stay away from box brand PSU's HP DELL......sometimes they use non standard pinning on the connector (the connector will actually be the ATX 20+4, wires in different locations tho)) |
When network interface is down, some nasty things happen, for instance tcp_connect returns without ever calling error callback. This change adds some workarounds for that: before doing a tcp connect and DNS resolve we check if there is a route available. Also added a listener for wifi events which stops (aborts) all the WiFiClients and WiFiUDPs when wifi is disconnected. This should help libraries detect disconnect properly.
When network interface is down, some nasty things happen, for instance tcp_connect returns without ever calling error callback. This change adds some workarounds for that: before doing a tcp connect and DNS resolve we check if there is a route available. Also added a listener for wifi events which stops (aborts) all the WiFiClients and WiFiUDPs when wifi is disconnected. This should help libraries detect disconnect properly. Conflicts: hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFi.h
When network interface is down, some nasty things happen, for instance tcp_connect returns without ever calling error callback. This change adds some workarounds for that: before doing a tcp connect and DNS resolve we check if there is a route available. Also added a listener for wifi events which stops (aborts) all the WiFiClients and WiFiUDPs when wifi is disconnected. This should help libraries detect disconnect properly.
Hi, Has somebody found a solution for this? Regards, |
I think the best workaround until now is to detect WiFi.Status != WL_CONNECTED, and do a short deepsleep so it reboot hardwise. Easy on a Wemos, but not so easy on a SonOff when the XPD_DCDC pin isn't connected to something. |
why can't the ESP just run instead of rebooting... because it can still check pin states or whatever else and store the data. but attempt a reconnect every so often. this is a micro controller.. it does many things... it shouldn't be hinged on having an IP address. what if the sole purpose to it was for scanning of AP and signal strengths and data logging the information?? it couldn't. And having an IP address or not does not mean it is not connected to wifi. it just means that it couldn't communicate with a DHCP server. which at that time you could have it connect to a different AP and then perform tasks to notify of a missing DHCP or whatever. but because of how not having an IP means it has no wifi connection and causes a reboot.. you can't achieve this. I know this is not a limitation of the ESP because micropython works in this manner. this is a limitation of this IDE |
@kdschlosser Can you share a sketch which causes ESP to boot loop if fails to get an IP address? Thanks. |
This was some time ago... I changed to doing something else and I do not know if i have the sketch wandering about. But i am assuming this is still an issue if there are people posting in a closed topic. There are examples in this topic.. I do not know if this has been fixed or not.. i don't understand why people would be posting if it has been. so I would guess that any of the above examples would show what the issue is. I know I posted in another thread about this same issue as i stated many moons ago. in this post. i mean try doing this to see if the ESP boot loops I remember doing something just like this and it never printed a single dot.. it kept on rebooting. and I am going to be completely honest with ya.. the answer I got which was something to the following "wl_connected only checks to see if you have an IP address that is dynamically assigned" and the length of time it took to get it. as well as another issue I had and the lack of a response to that one as well. and when i did get one it was some crazy workaround because using Serial.println had incredibly slow sends. like 2-3 CPS because of some issue with it only sending one byte per packet. or some nonsense. and there was no documentation explaining how to send because of this. all kind of drove me away from using this library. and i am sure that it has developed and become a great library.. but in the end those kinds of responses to people that are having a problem makes them not want to use it. it took 4 months and having the door closed on me once about it (i believe i was the first to point this out...) and then as more people started having the same problem.. then all of a sudden there was a problem with it.. |
This morning I tried to make a simple sketch to see more exactly if the problem was during sending or receiving. But with this sketch it just will not reproduce the error. My ESP.restart() after loosing wifi connection reboots the esp correctly, BUT what I also noticed is that the well known(?) problem with ESP.Restart() after serial download also was gone. Can this 2 issues be related? I need some more time (that I don't have right now...) to sort out what i have in my other sketches that can lead me to the problem. The httpupdate for example is something that I use in all my sketches. |
One step forward and two step backwards.... It quite sure now that this crash: **Soft WDT reset ctx: cont
ets Jan 8 2013,rst cause:2, boot mode:(3,6) load 0x4010f000, len 1384, room 16 happens when i'm reading the receiving buffer, and loosing Wifi connection at the same time. My test setup: |
I am on the latest board version i.e 2.4.1 and also on latest commit but still this problem persists. |
I think there is a misunderstanding of what WL_CONNECTED is. WL_CONNECTED or "Wireless LAN Connected" as it would have you believe has absolutely nothing to do with being connected to a wireless lan. it has everything to do with having an IP address. which is not the same thing. I believe what folks are wanting is a way to test to see if their WiFi dropped them. because you can still have an IP address and not a WiFi connection. this is called a static IP address. This specific feature is useless in detecting a connection loss even with DHCP because if you have your lease time set to say 1 hour (which i would never do do to the extra traffic) you would not know until the lease expired in this case it could be up to an hour later. As to why it causes a reboot of the ESP if there is no IP address is beyond me it should not do this. It should allow you to continue to do other tasks in the event there is no IP address at the very least. Like allow you to try and connect to a different network. But the WL_CONNECTED name needs to be gone and changed out for HAS_IP_ADDRESS or something of the sort. This issue has been here 3 years. I do not think it will ever get corrected and i do not think that the developers care. or maybe they simply do not want to say we have no clue why it is doing it and we have no clue how to fix it. Which I would be OK with instead of no response. Maybe a new topic needs to be created because this one is closed??? (why i have no idea problem has not been solved). |
If ESP tries to send something over WiFi while WiFi network suddenly switches of, there is 99% chance to hang ESP.
I use following code to debug with Socket Test Tool (http://sourceforge.net/projects/sockettest/):
I got following output:
After that ESP can be reset only by hardware button.
The text was updated successfully, but these errors were encountered: