atanisoft / HttpServer

HTTP Server implemented using OpenMRN StateFlow patterns.
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

Websocket: handler is invoked for disconnect prior to connect #5

Closed atanisoft closed 4 years ago

atanisoft commented 4 years ago

If the handshake process fails the websocket handler is being invoked during disconnect even though it has not been invoked for the connect event:

[WebSocket fd:52] read-error (22: Invalid argument), disconnecting (handshake)
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x400ee4fb  PS      : 0x00060630  A0      : 0x800f0dd8  A1      : 0x3ffd2de0  
A2      : 0xfffffffc  A3      : 0x3ffb4864  A4      : 0x00000000  A5      : 0x3ffae9d8  
A6      : 0x00000000  A7      : 0x00000000  A8      : 0x800dd668  A9      : 0x3ffd2da0  
A10     : 0x00000001  A11     : 0x00000000  A12     : 0x3ffbc064  A13     : 0x00000000  
A14     : 0x00000000  A15     : 0x00000000  SAR     : 0x00000004  EXCCAUSE: 0x0000001c  
EXCVADDR: 0xfffffffc  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xfffffffc  

Backtrace:0x400ee4f8:0x3ffd2de0 0x400f0dd5:0x3ffd2e00 0x401a8bc5:0x3ffd2e60 0x40111392:0x3ffd2e80 0x401114a5:0x3ffd2eb0 0x4011d0ad:0x3ffd2ee0 0x4011ceb9:0x3ffd2f10 0x401a9829:0x3ffd2f40 0x40128727:0x3ffd2f60
0x400ee4f8: std::unique_ptr<WebSocketClient, std::default_delete<WebSocketClient> >::~unique_ptr() at xtensa-esp32-elf/include/c++/8.2.0/bits/unique_ptr.h:270

0x400f0dd5: process_websocket_event(http::WebSocketFlow*, http::WebSocketEvent, unsigned char const*, unsigned int) at xtensa-esp32-elf/include/c++/8.2.0/ext/new_allocator.h:140
 (inlined by) ?? at xtensa-esp32-elf/include/c++/8.2.0/bits/alloc_traits.h:487
 (inlined by) ?? at xtensa-esp32-elf/include/c++/8.2.0/bits/vector.tcc:165
 (inlined by) ?? at xtensa-esp32-elf/include/c++/8.2.0/bits/stl_vector.h:1318
 (inlined by) process_websocket_event(http::WebSocketFlow*, http::WebSocketEvent, unsigned char const*, unsigned int) at ESP32CommandStation/build/../main/WebServer.cpp:451
0x401a8bc5: std::_Function_handler<void (http::WebSocketFlow*, http::WebSocketEvent, unsigned char*, unsigned int), void (*)(http::WebSocketFlow*, http::WebSocketEvent, unsigned char const*, unsigned int)>::_M_invoke(std::_Any_data const&, http::WebSocketFlow*&&, http::WebSocketEvent&&, unsigned char*&&, unsigned int&&) at xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:297
0x40111392: std::function<void (http::WebSocketFlow*, http::WebSocketEvent, unsigned char*, unsigned int)>::operator()(http::WebSocketFlow*, http::WebSocketEvent, unsigned char*, unsigned int) const at xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:687
0x401114a5: http::WebSocketFlow::shutdown_connection() at ESP32CommandStation/build/../components/HttpServer/src/HttpRequestWebSocket.cpp:376
0x4011d0ad: StateFlowBase::run() at ESP32CommandStation/build/../components/OpenMRNLite/src/executor/StateFlow.cpp:63 (discriminator 4)
0x4011ceb9: ExecutorBase::entry() at ESP32CommandStation/build/../components/OpenMRNLite/src/executor/Executor.cpp:324
0x401a9829: OSThread::start(void*) at ESP32CommandStation/build/../components/OpenMRNLite/src/os/OS.hxx:193
0x40128727: os_thread_start at ESP32CommandStation/build/../components/OpenMRNLite/src/os/os.c:391