wifi crashes while reconnecting
Closed this issue · 2 comments
D (58542) event: SYSTEM_EVENT_STA_DISCONNECTED, ssid:cosmos, ssid_len:6, bssid:24:7f:20:5f:70:41, reason:7
D (58552) tcpip_adapter: check: local, if=0 fn=0x40116578
0x40116578: tcpip_adapter_down_api at /Users/kris/Dev/iot/ESP32/esp-idf/components/tcpip_adapter/./tcpip_adapter_lwip.c:942
D (58558) tcpip_adapter: if0 start ip lost tmr: enter
D (58563) tcpip_adapter: if0 start ip lost tmr: interval=120
D (58569) tcpip_adapter: call api in lwip: ret=0x0, give sem
D (58574) tcpip_adapter: check: remote, if=0 fn=0x40116578
0x40116578: tcpip_adapter_down_api at /Users/kris/Dev/iot/ESP32/esp-idf/components/tcpip_adapter/./tcpip_adapter_lwip.c:942
D (58580) wifi: Station disconnected - reconnecting
Guru Meditation Error of type LoadProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x4011d73e PS : 0x00060a30 A0 : 0x8011d8a2 A1 : 0x3ffbdb80
0x4011d73e: restore_wifi_setup at /Users/kris/Dev/iot/ESP32/workspace/pmsensor/components/bootwifi/./bootwifi.c:432
A2 : 0x00000001 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x3ffbba3c
A6 : 0x00000001 A7 : 0x00000005 A8 : 0x8011d712 A9 : 0x3ffbdb60
A10 : 0x00000000 A11 : 0x00060a20 A12 : 0x3ffbdbd0 A13 : 0x0000000c
A14 : 0x00000000 A15 : 0x00000005 SAR : 0x00000007 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000001 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffe
Backtrace: 0x4011d73e:0x3ffbdb80 0x4011d89f:0x3ffbdc10 0x40127f4d:0x3ffbdc50 0x40127f91:0x3ffbdc70
0x4011d73e: restore_wifi_setup at /Users/kris/Dev/iot/ESP32/workspace/pmsensor/components/bootwifi/./bootwifi.c:432
0x4011d89f: esp32_wifi_eventHandler at /Users/kris/Dev/iot/ESP32/workspace/pmsensor/components/bootwifi/./bootwifi.c:303 (discriminator 1)
0x40127f4d: esp_event_post_to_user at /Users/kris/Dev/iot/ESP32/esp-idf/components/esp32/./event_loop.c:94
0x40127f91: esp_event_loop_task at /Users/kris/Dev/iot/ESP32/esp-idf/components/esp32/./event_loop.c:94
this is tricky to reproduce and involves wifi, mongoose and maybe mbedtls.
it seems that if SSL request fails due to no network connectivity, it somehow hands mongoose.
additional issue is that it is hard to trigger SYSTEM_EVENT_STA_DISCONNECTED; especially when I'm trying to do this inside unit test, OS fails to report this event on time (see espressif/esp-idf#1076)
w/o mongoose everything works fine and requests timeout properly w/o network, even if OS sometimes is late with 'disconnect' events.
under some circumstances however (mbedtls failed in handshake, due to network issue?), mongoose mg_mgr_poll loop goes crazy, and internal debug log reveals:
mg_mgr_handle_conn 0x3ffca414 fd=0 fd_flags=1 nc_flags=1 rmbl=0 smbl=0
mg_accept_conn 0x3ffca414: failed to accept: 0
mg_mgr_handle_conn 0x3ffca414 after fd=0 nc_flags=1 rmbl=0 smbl=0
probably because of some problem with server socket?
a bit similar issue: cesanta/mongoose#780
some ideas:
- upgrade mongoose
- stop mongoose on disconnect
- use simpler server