-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ESP32 websocket crash at AsyncClient::space() #739
Comments
I figured out where in the code is the problem but not sure why. It is when calling the WebSocket onEvent function which looks like:
that is initialised before the server.begin() as If I comment out the onEvent function everything works as it should. What I am missing? |
Your sketch shows not the whole sourcecode. Push all, inclusive your onEvent handler. |
I updated the repository here |
If you remove your client cleanup functionality, does it still crash? |
Yes it still does. It seems that the problem is that it trys to send two messages at the same time? one from Try it yourself, it is a very simple example |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions. |
Hello,
My ESP32 keep crashing when using this library with websocket. The crash happens after I refresh Safari in my Iphone while my computer with Firefox is also connected to the server (i.e. two clients). Refreshing Firefox with my Iphone connected does NOT cause a crash (I tested several times). However if I refresh very fast my computer I get the crash.
Also tried Microsoft Edge in my phone with the same results.
Appreciate any help! :)
Hardware
MacBook Air, Mojave
Wemos LOLIN D32 Pro
CAN transceiver SN65HVD230
Software
Platformio.io Core 4.3.1, Home 3.1.1 using Visual Code IDE
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/lolin_d32_pro.html
PLATFORM: Espressif 32 1.12.0 > WEMOS LOLIN D32 PRO
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 29 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ESP Async WebServer 1.2.3
| |-- AsyncTCP 1.1.1
| |-- WiFi 1.0
| |-- FS 1.0
| |-- ArduinoJson 6.15.0
|-- WiFi 1.0
|-- ArduinoJson 6.15.0
|-- Ticker 1.1
|-- ESPmDNS 1.0
| |-- WiFi 1.0
|-- SPIFFS 1.0
| |-- FS 1.0
Building in release mode
Retrieving maximum program size .pio/build/lolin_d32_pro/firmware.elf
Checking size .pio/build/lolin_d32_pro/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 14.1% (used 46192 bytes from 327680 bytes)
Flash: [======== ] 77.8% (used 1020005 bytes from 1310720 bytes)
CAN driver from ESP-IDF
Sketch
See attached file here.
Backtrace from Platformio
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x40181657 PS : 0x00060930 A0 : 0x8016d24c A1 : 0x3ffd37d0
A2 : 0x00000000 A3 : 0x40084f08 A4 : 0x00000001 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x8000beb2 A9 : 0x3ffd37b0
A10 : 0x3ffd4e64 A11 : 0x00000008 A12 : 0x3ffd38ec A13 : 0x3ffd38f0
A14 : 0x3ffd38f4 A15 : 0x3ffd38f8 SAR : 0x00000010 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x4000c349 LEND : 0x4000c36b LCOUNT : 0xffffffff
Backtrace: 0x40181657:0x3ffd37d0 0x4016d249:0x3ffd37f0 0x400d41fc:0x3ffd3810 0x400d4227:0x3ffd3830 0x400d423d:0x3ffd3850 0x400d424d:0x3ffd3870 0x400d17a4:0x3ffd3890 0x4017dcdf:0x3ffd38b0 0x4017df9e:0x3ffd38d0 0x400d475d:0x3ffd3920 0x400d477d:0x3ffd3940 0x400d48d5:0x3ffd3960 0x400d4922:0x3ffd39a0 0x400d492f:0x3ffd39c0 0x4016d512:0x3ffd39e0 0x4016d646:0x3ffd3a10 0x4016d65c:0x3ffd3a30 0x4016d91e:0x3ffd3a50 0x40088b7d:0x3ffd3a80
Decoding of backtrace
#0 0x40181657:0x3ffd37d0 in AsyncClient::space() at /AsyncTCP_ID1826/src/AsyncTCP.cpp:1020
#1 0x4016d249:0x3ffd37f0 in AsyncClient::canSend() at /AsyncTCP_ID1826/src/AsyncTCP.cpp:1020
#2 0x400d41fc:0x3ffd3810 in AsyncWebSocketClient::_queueMessage(AsyncWebSocketMessage*) at /ESP Async WebServer_ID306/src/AsyncWebSocket.cpp:850
#3 0x400d4227:0x3ffd3830 in AsyncWebSocketClient::text(char const*, unsigned int) at /ESP Async WebServer_ID306/src/AsyncWebSocket.cpp:850
#4 0x400d423d:0x3ffd3850 in AsyncWebSocketClient::text(char*) at /ESP Async WebServer_ID306/src/AsyncWebSocket.cpp:850
#5 0x400d424d:0x3ffd3870 in AsyncWebSocketClient::text(char const*) at ??:?
#6 0x400d17a4:0x3ffd3890 in onEvent(AsyncWebSocket*, AsyncWebSocketClient*, AwsEventType, void*, unsigned char*, unsigned int) at src/inclino_server.cpp:25
#7 0x4017dcdf:0x3ffd38b0 in std::_Function_handler<void (AsyncWebSocket*, AsyncWebSocketClient*, AwsEventType, void*, unsigned char*, unsigned int), void ()(AsyncWebSocket, AsyncWebSocketClient*, AwsEventType, void*, unsigned char*, unsigned int)>::_M_invoke(std::_Any_data const&, AsyncWebSocket*&&, AsyncWebSocketClient*&&, AwsEventType&&, void*&&, unsigned char*&&, unsigned int&&) at /Users/pan/.platformio/packages/toolchain-xtensa32@2.50200.80/xtensa-esp32-elf/include/c++/5.2.0/functional:1871
#8 0x4017df9e:0x3ffd38d0 in std::function<void (AsyncWebSocket*, AsyncWebSocketClient*, AwsEventType, void*, unsigned char*, unsigned int)>::operator()(AsyncWebSocket*, AsyncWebSocketClient*, AwsEventType, void*, unsigned char*, unsigned int) const at /Users/pan/.platformio/packages/toolchain-xtensa32@2.50200.80/xtensa-esp32-elf/include/c++/5.2.0/functional:2271
(inlined by) AsyncWebSocket::_handleEvent(AsyncWebSocketClient*, AwsEventType, void*, unsigned char*, unsigned int) at /ESP Async WebServer_ID306/src/AsyncWebSocket.cpp:872
#9 0x400d475d:0x3ffd3920 in AsyncWebSocketClient::~AsyncWebSocketClient() at /ESP Async WebServer_ID306/src/AsyncWebSocket.cpp:850
#10 0x400d477d:0x3ffd3940 in std::_Function_handler<void (AsyncWebSocketClient* const&), AsyncWebSocket::AsyncWebSocket(String const&)::{lambda(AsyncWebSocketClient*)#1}>::_M_invoke(std::_Any_data const&, AsyncWebSocketClient* const&) at /ESP Async WebServer_ID306/src/AsyncWebSocket.cpp:850
(inlined by) _M_invoke at /Users/pan/.platformio/packages/toolchain-xtensa32@2.50200.80/xtensa-esp32-elf/include/c++/5.2.0/functional:1871
#11 0x400d48d5:0x3ffd3960 in std::function<void (AsyncWebSocketClient* const&)>::operator()(AsyncWebSocketClient* const&) const at /ESP Async WebServer_ID306/src/AsyncWebSocket.cpp:850
(inlined by) LinkedList<AsyncWebSocketClient*, LinkedListNode>::remove_first(std::function<bool (AsyncWebSocketClient* const&)>) at /ESP Async WebServer_ID306/src/StringArray.h:150
(inlined by) AsyncWebSocket::_handleDisconnect(AsyncWebSocketClient*) at /ESP Async WebServer_ID306/src/AsyncWebSocket.cpp:884
#12 0x400d4922:0x3ffd39a0 in AsyncWebSocketClient::_onDisconnect() at /ESP Async WebServer_ID306/src/AsyncWebSocket.cpp:850
#13 0x400d492f:0x3ffd39c0 in std::_Function_handler<void (void*, AsyncClient*), AsyncWebSocketClient::AsyncWebSocketClient(AsyncWebServerRequest*, AsyncWebSocket*)::{lambda(void*, AsyncClient*)#5}>::_M_invoke(std::_Any_data const&, void*&&, AsyncClient*&&) at /ESP Async WebServer_ID306/src/AsyncWebSocket.cpp:850
(inlined by) _M_invoke at /Users/pan/.platformio/packages/toolchain-xtensa32@2.50200.80/xtensa-esp32-elf/include/c++/5.2.0/functional:1871
#14 0x4016d512:0x3ffd39e0 in std::function<void (void*, AsyncClient*)>::operator()(void*, AsyncClient*) const at /AsyncTCP_ID1826/src/AsyncTCP.cpp:1020
#15 0x4016d646:0x3ffd3a10 in AsyncClient::_fin(tcp_pcb*, signed char) at /AsyncTCP_ID1826/src/AsyncTCP.cpp:1020
#16 0x4016d65c:0x3ffd3a30 in AsyncClient::_s_fin(void*, tcp_pcb*, signed char) at /AsyncTCP_ID1826/src/AsyncTCP.cpp:1020
#17 0x4016d91e:0x3ffd3a50 in _async_service_task(void*) at /AsyncTCP_ID1826/src/AsyncTCP.cpp:1020
(inlined by) _async_service_task at /AsyncTCP_ID1826/src/AsyncTCP.cpp:194
#18 0x40088b7d:0x3ffd3a80 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)
The text was updated successfully, but these errors were encountered: