WiFi connection works only after router reboot

davidgyoung
Posts: 2
Joined: Wed Dec 05, 2018 10:22 pm

WiFi connection works only after router reboot

Postby davidgyoung » Mon Dec 10, 2018 8:12 pm

Hardware: ESP-WROOM-32
ESP-IDF commit hash: 12b2268ee56dac79988b75dbb49a453629ed8022

When running the example esp-idf/examples/protocols/https_request, the code will connect to my WiFi network the first time, but it won't connect again. Even if I power off the ESP-WROOM-32 board and power it back on, it won't connect a second time. In order to connect a second time, I must reboot my WiFi router or hotspot. Once I do that, it connects exactly once again, then fails.

Here's the log output when it fails to connect, and below that is the log output when it succeeds in connecting. Note in the failed example it gets part way through the connection process, but it never gets a event: sta log line. Why won't it connect without rebooting my router?

Fail:

Code: Select all

I (0) cpu_start: App cpu up.
I (439) heap_init: Initializing. RAM available for dynamic allocation:
I (446) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (452) heap_init: At 3FFB91B8 len 00026E48 (155 KiB): DRAM
I (458) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (464) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (471) heap_init: At 400914E0 len 0000EB20 (58 KiB): IRAM
I (477) cpu_start: Pro cpu start user code
I (159) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (242) wifi: wifi driver task: 3ffc0e08, prio:23, stack:3584, core=0
I (242) wifi: wifi firmware version: a85ca5e
I (242) wifi: config NVS flash: enabled
I (242) wifi: config nano formating: disabled
I (242) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (252) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (292) wifi: Init dynamic tx buffer num: 32
I (292) wifi: Init data frame dynamic rx buffer num: 32
I (292) wifi: Init management frame dynamic rx buffer num: 32
I (292) wifi: Init static rx buffer size: 1600
I (292) wifi: Init static rx buffer num: 10
I (302) wifi: Init dynamic rx buffer num: 32
I (302) example: Setting WiFi configuration SSID libertariandictator...
I (372) phy: phy_version: 4000, b6198fa, Sep  3 2018, 15:11:06, 0, 0
I (372) wifi: mode : sta (24:0a:c4:1d:27:b0)
I (1702) wifi: n:11 0, o:1 0, ap:255 255, sta:11 0, prof:1
I (2692) wifi: state: init -> auth (b0)
I (2692) wifi: state: auth -> assoc (0)
I (3692) wifi: state: assoc -> init (400)
I (3692) wifi: n:11 0, o:11 0, ap:255 255, sta:11 0, prof:1
I (6232) wifi: n:11 0, o:11 0, ap:255 255, sta:11 0, prof:1
I (6232) wifi: state: init -> auth (b0)
I (7232) wifi: state: auth -> init (200)
I (7232) wifi: n:11 0, o:11 0, ap:255 255, sta:11 0, prof:1
I (9772) wifi: n:11 0, o:11 0, ap:255 255, sta:11 0, prof:1
I (9772) wifi: state: init -> auth (b0)
I (10772) wifi: state: auth -> init (200)
I (10772) wifi: n:11 0, o:11 0, ap:255 255, sta:11 0, prof:1
I (13302) wifi: n:11 0, o:11 0, ap:255 255, sta:11 0, prof:1
Success:

Code: Select all

I (0) cpu_start: App cpu up.
I (439) heap_init: Initializing. RAM available for dynamic allocation:
I (446) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (452) heap_init: At 3FFB91B8 len 00026E48 (155 KiB): DRAM
I (458) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (464) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (471) heap_init: At 400914E0 len 0000EB20 (58 KiB): IRAM
I (477) cpu_start: Pro cpu start user code
I (159) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (242) wifi: wifi driver task: 3ffc0e08, prio:23, stack:3584, core=0
I (242) wifi: wifi firmware version: a85ca5e
I (242) wifi: config NVS flash: enabled
I (242) wifi: config nano formating: disabled
I (242) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (252) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (292) wifi: Init dynamic tx buffer num: 32
I (292) wifi: Init data frame dynamic rx buffer num: 32
I (292) wifi: Init management frame dynamic rx buffer num: 32
I (292) wifi: Init static rx buffer size: 1600
I (292) wifi: Init static rx buffer num: 10
I (302) wifi: Init dynamic rx buffer num: 32
I (302) example: Setting WiFi configuration SSID libertariandictator...
I (372) phy: phy_version: 4000, b6198fa, Sep  3 2018, 15:11:06, 0, 0
I (372) wifi: mode : sta (24:0a:c4:1d:27:b0)
I (21012) wifi: n:11 0, o:1 0, ap:255 255, sta:11 0, prof:1
I (21992) wifi: state: init -> auth (b0)
I (22002) wifi: state: auth -> assoc (0)
I (22012) wifi: state: assoc -> run (10)
I (22042) wifi: connected with libertariandictator, channel 11
I (22042) wifi: pm start, type: 1

I (22742) event: sta ip: 192.168.43.248, mask: 255.255.255.0, gw: 192.168.43.152
I (22742) example: Connected to AP
I (25652) example: Connection established...
I (25652) example: 106 bytes written
I (25652) example: Reading HTTP response...

littlesky
Posts: 51
Joined: Fri Jun 09, 2017 7:49 am

Re: WiFi connection works only after router reboot

Postby littlesky » Tue Dec 11, 2018 2:34 am

Could you please tell us the brand and firmware version of the router? It is also appreciated to capture the packets of the connection procedure and provide to us.

davidgyoung
Posts: 2
Joined: Wed Dec 05, 2018 10:22 pm

Re: WiFi connection works only after router reboot

Postby davidgyoung » Tue Dec 11, 2018 11:04 pm

I originally thought the problem was router-specific, so I tried it on several -- ones under my control and ones not. I can only reboot routers under my control, so the easiest way I can reproduce it is using a Hotspot on my Android 8.1 Nokia 6.1+. If I turn the hotspot off and turn it back on, the ESP32 will reconnect. I can also reproduce it on my home TP-Link N300 router. If I reboot it, the ESP32 will reconnect.

On other routers not under my control (ones I cannot reboot) I can effectively connect only one time.

I suspect this issue is not router-specific since I have never seen it not happen on a half-dozen routers where I have tried. My (poorly?) educated guess is that when the router has already provided a DHCP lease, the reconnection handshake is different somehow, so it doesn't complete in that case. Rebooting the router would release the DHCP lease.

Again, this happens for me with an unmodified copy of the reference code used to connect over HTTPS, so I'm surprised this is not a common issue.

I'm not sure how I could capture the WiFi packets during the connection. I might be able to set up a computer to use Wireshark, but I'm not enough of a networking expert to do that without it becoming a pretty big side project for me.

Buccaneer6
Posts: 2
Joined: Mon Apr 10, 2023 3:48 pm

Re: WiFi connection works only after router reboot

Postby Buccaneer6 » Wed Feb 21, 2024 11:19 pm

Although years ago, did you ever find a solution?

Who is online

Users browsing this forum: Baidu [Spider] and 85 guests