Page 1 of 1

Wifi reconnect takes a long time

Posted: 21 Aug 2021, 13:05
by lamama1234
Hi,

I'm a newbie to ESPEasy, and tried to search for common issues in this forum but couldn't find.

I installed ESP_Easy_mega_20210503_normal_alt_wifi_ESP8266_4M1M on my ESP8266 NodeMCU and everything is working perfectly, except for the fact that when ESPEasy looses wifi connection (e.g. upon router restart), it takes forever to reconnect. Sometime up until 1 hr or more. RSSI is ~-73dbm so not super strong but still valid.

Are there any ESPEasy settings I can play with to make wifi reconnect faster?

thanks!
Screenshot 2021-08-21 140511.png
Screenshot 2021-08-21 140511.png (484.8 KiB) Viewed 7890 times

Re: Wifi reconnect takes a long time

Posted: 21 Aug 2021, 13:10
by Ath
You should start by updating to the latest release of ESPEasy, 20210802, available from the releases page, that will greatly improve your WiFi connection, because of the many fixes that have been done since that May release.
The alt_wifi release should *only* be used if the normal release-build isn't working as expected.

Re: Wifi reconnect takes a long time

Posted: 21 Aug 2021, 13:18
by lamama1234
Ath wrote: 21 Aug 2021, 13:10 You should start by updating to the latest release of ESPEasy, 20210802, available from the releases page, that will greatly improve your WiFi connection, because of the many fixes that have been done since that May release.
The alt_wifi release should *only* be used if the normal release-build isn't working as expected.
Thanks. Can I update OTA? Also, once updating, will I need to re-define all previous devices/events?

Re: Wifi reconnect takes a long time

Posted: 21 Aug 2021, 13:37
by Ath
lamama1234 wrote: 21 Aug 2021, 13:18 Can I update OTA?
Yes
lamama1234 wrote: 21 Aug 2021, 13:18 Also, once updating, will I need to re-define all previous devices/events?
No, if the Flash layout stays the same (4M1M) all settings will be preserved.

Re: Wifi reconnect takes a long time

Posted: 21 Aug 2021, 13:47
by lamama1234
Ath wrote: 21 Aug 2021, 13:37
lamama1234 wrote: 21 Aug 2021, 13:18 Can I update OTA?
Yes
lamama1234 wrote: 21 Aug 2021, 13:18 Also, once updating, will I need to re-define all previous devices/events?
No, if the Flash layout stays the same (4M1M) all settings will be preserved.
Many thanks!

Re: Wifi reconnect takes a long time

Posted: 26 Aug 2021, 13:37
by lamama1234
Ath wrote: 21 Aug 2021, 13:10 You should start by updating to the latest release of ESPEasy, 20210802, available from the releases page, that will greatly improve your WiFi connection, because of the many fixes that have been done since that May release.
The alt_wifi release should *only* be used if the normal release-build isn't working as expected.
Hi again. I installed the latest available firmware:

ESP_Easy_mega_20210802_normal_ESP8266_4M1M Aug 2 2021

but still, reconnecting to wifi take a lot of time (>1 hr if at all).

Any other settings I can play with to fix that?

Thanks

Re: Wifi reconnect takes a long time

Posted: 26 Aug 2021, 14:05
by TD-er
Can you be a bit more specific about your WiFi setup?
For example, are you using hidden SSID?
Is your WiFi configured to be a WiFi mesh?
Do you have lots of hidden SSID access points in your area (easiest to see on the /setup page or when performing a WiFi scan)

What configuration do you use in ESPEasy? (almost all in the last section of the Tools->Advanced page)

Re: Wifi reconnect takes a long time

Posted: 26 Aug 2021, 16:36
by lamama1234
TD-er wrote: 26 Aug 2021, 14:05 Can you be a bit more specific about your WiFi setup?
For example, are you using hidden SSID?
Is your WiFi configured to be a WiFi mesh?
Do you have lots of hidden SSID access points in your area (easiest to see on the /setup page or when performing a WiFi scan)

What configuration do you use in ESPEasy? (almost all in the last section of the Tools->Advanced page)
Sure. I'm not using a hidden SSID and no other hidden SSIDs in my proximity.

I am using a mesh based system (Asus AiMesh with main router and one other node).

I'm also attaching my settings last section configuration:
IMG_20210826_173050.jpg
IMG_20210826_173050.jpg (294.43 KiB) Viewed 7732 times
IMG_20210826_173013.jpg
IMG_20210826_173013.jpg (299.67 KiB) Viewed 7732 times

Re: Wifi reconnect takes a long time

Posted: 26 Aug 2021, 17:31
by TD-er
OK, that looks OK to me.
At least nothing I would immediately suggest to try.

About the WiFi mesh setup of your APs.
Given it is a WiFi mesh setup, maybe you can try to set the "Extra WiFi scan loops" to 1 or 2.
What this does, is the ESP will loop 2 or 3 times over all channels when a scan is needed.
This usually results in more found APs in a scan.
Maybe the "best" AP is not always found in a single scan and then the ESP may try to connect to the least favorable AP.

Do you have any setting like an RSSI threshold in the mesh configuration?
For example a settings which only allows a unit to connect if its RSSI is above some level.
If the ESP then always tries to connect to the "wrong" AP, the RSSI of the WiFI signal from the ESP may be too low and the other AP may report it does receive the same unit with a stronger signal.

Other settings to look for:
- Beacon interval. (Typically this is 102.4 msec, so if it differs, please tell)
- Some timeout settings. (sometimes expressed as a "distance" value or "near"/"far")

Re: Wifi reconnect takes a long time

Posted: 27 Aug 2021, 15:46
by Rini52
lamama1234 wrote: 26 Aug 2021, 16:36
TD-er wrote: 26 Aug 2021, 14:05 Can you be a bit more specific about your WiFi setup?
For example, are you using hidden SSID?
Is your WiFi configured to be a WiFi mesh?
Do you have lots of hidden SSID access points in your area (easiest to see on the /setup page or when performing a WiFi scan)

What configuration do you use in ESPEasy? (almost all in the last section of the Tools->Advanced page)
Sure. I'm not using a hidden SSID and no other hidden SSIDs in my proximity.

I am using a mesh based system (Asus AiMesh with main router and one other node).

I'm also attaching my settings last section configuration:

IMG_20210826_173050.jpg

IMG_20210826_173013.jpg
I also have a Asus mesh. Build a custom flash based on latest (202108) from TD, but use a static ip adress. This I find in previous test worked best to connect. I also include AP settings (prim+ Fallback) in the flash so it connects straight to the AP from a cold boot. This works most of the time. Indeed you have to check the db(RSSI) setting in the mess router that it doesn't disconnect if the strength falls below that value. It happen to me one time and than the only way to reconnect the ESP8266 is by cold reboot.

Re: Wifi reconnect takes a long time

Posted: 27 Aug 2021, 20:27
by lamama1234
Rini52 wrote: 27 Aug 2021, 15:46
lamama1234 wrote: 26 Aug 2021, 16:36
TD-er wrote: 26 Aug 2021, 14:05 Can you be a bit more specific about your WiFi setup?
For example, are you using hidden SSID?
Is your WiFi configured to be a WiFi mesh?
Do you have lots of hidden SSID access points in your area (easiest to see on the /setup page or when performing a WiFi scan)

What configuration do you use in ESPEasy? (almost all in the last section of the Tools->Advanced page)
Sure. I'm not using a hidden SSID and no other hidden SSIDs in my proximity.

I am using a mesh based system (Asus AiMesh with main router and one other node).

I'm also attaching my settings last section configuration:

IMG_20210826_173050.jpg

IMG_20210826_173013.jpg
I also have a Asus mesh. Build a custom flash based on latest (202108) from TD, but use a static ip adress. This I find in previous test worked best to connect. I also include AP settings (prim+ Fallback) in the flash so it connects straight to the AP from a cold boot. This works most of the time. Indeed you have to check the db(RSSI) setting in the mess router that it doesn't disconnect if the strength falls below that value. It happen to me one time and than the only way to reconnect the ESP8266 is by cold reboot.
Thanks guys. I think I found a lead - it happens when my esp is changing connection from the main router (with better RSSI) to the other node. Through my mesh UI I am able to see my esp with the same ip as before, but it's web UI is unreachable and it doesn't communicate with my Domoticz server.

I will try to assign a static IP (at client side or router?) and see if it helps.

Thanks

Re: Wifi reconnect takes a long time

Posted: 27 Aug 2021, 20:58
by TD-er
You may also want to send Gratuituous ARP packets from the ESP.
This may help other devices in your network to be able to reach the ESP.
... at least if the ESP is considering itself as connected.

It is possible the ESP does not complete all connect stages and then it may stay for a long time in such a limbo state.
Typically this happens if an event is not received in ESPEasy (event from the wifi layer, not related to the rules).
I have seen that happen sometimes, but I find it hard to reproduce.

Re: Wifi reconnect takes a long time

Posted: 27 Aug 2021, 21:06
by Ath
The static IP should be set at ESPEasy, on the Config tab. You should fill all 4 fields of WiFi IP Settings, usually the Gateway and DNS are the IP address of the router, and the subnet mask will most likely be 255.255.255.0

Re: Wifi reconnect takes a long time

Posted: 01 Sep 2021, 09:34
by lamama1234
Thanks guys, seems to be working ok now.

Appreciate it!

Re: Wifi reconnect takes a long time

Posted: 01 Sep 2021, 09:38
by TD-er
What was the fix?

Re: Wifi reconnect takes a long time

Posted: 01 Sep 2021, 09:47
by lamama1234
TD-er wrote: 01 Sep 2021, 09:38 What was the fix?
I changed 3 things:

1. Fixed IP set by ESPEasy
2. Gratuituous ARP
3. Binded the unit to my main router (disabled roaming to node)

I will try to remove #2 and see if it still connects.

Re: Wifi reconnect takes a long time

Posted: 01 Sep 2021, 10:02
by TD-er
Gratuituous ARP has the function to tell the switches and APs in your network at what port one can reach the device with a specific MAC address.
So it will not fix (re)connecting to an AP, but it will help to find the node so other devices can communicate with it.
It may also fix reachability right after a node is connected to another AP.
But without Gratuituous ARP enabled, it will eventually appear reachable after some time.

The main problem with the ESP via WiFi is that it is not always receiving ARP requests, so it may not answer them.
Thus by proactively answering ARP requests, before they are even asked, you also tell the switches and APs in your network to store the MAC address in their MAC tables along with the port on which they heard the Gratuituous ARP (or normal ARP reply) packet

Re: Wifi reconnect takes a long time

Posted: 01 Sep 2021, 11:52
by lamama1234
TD-er wrote: 01 Sep 2021, 10:02 Gratuituous ARP has the function to tell the switches and APs in your network at what port one can reach the device with a specific MAC address.
So it will not fix (re)connecting to an AP, but it will help to find the node so other devices can communicate with it.
It may also fix reachability right after a node is connected to another AP.
But without Gratuituous ARP enabled, it will eventually appear reachable after some time.

The main problem with the ESP via WiFi is that it is not always receiving ARP requests, so it may not answer them.
Thus by proactively answering ARP requests, before they are even asked, you also tell the switches and APs in your network to store the MAC address in their MAC tables along with the port on which they heard the Gratuituous ARP (or normal ARP reply) packet
Got it. I mainly need my ESP to send out data so probably won't be affected much by cancelling Gratuituous ARP. I will give it a try and report back.

Tnx again

Re: Wifi reconnect takes a long time

Posted: 09 Sep 2021, 13:58
by lamama1234
Just as a follow-up, cancelling Gratuituous ARP didn't affect connectivity. Everything is working ok now. Thanks everybody!

Re: Wifi reconnect takes a long time

Posted: 09 Sep 2021, 23:26
by TD-er
Thanks for the update