Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket handler core panic #50

Closed
T94T opened this issue Jan 3, 2024 · 7 comments
Closed

WebSocket handler core panic #50

T94T opened this issue Jan 3, 2024 · 7 comments

Comments

@T94T
Copy link

T94T commented Jan 3, 2024

We really like this implementation of an http/https web server. Thanks a lot!

Currently we are experiencing a problem that is causing the ESP32 to crash.

WebSocket client: https://github.com/hoeken/PsychicHttp/blob/26b49f73dca48fa333361fb4a4cfeebca802eeda/examples/websockets/data/www/index.html

The ESP32 runs our custom firmware including the repository's example code:

server.on("/ws", &websocketHandler);
websocketHandler.onFrame([](PsychicWebSocketRequest *request, httpd_ws_frame *frame) {
  Serial.printf("[socket] #%d sent: %s\n", request->client()->socket(), (char *)frame->payload);
  return request->reply(frame);
});

Receiving WebSocket messages works fine without any errors. As soon as a packet is sent to the ESP32, it crashes:

[ 29135][I][PsychicWebSocket.cpp:175] handleRequest(): [psychic] frame len is 5
[ 29136][I][PsychicWebSocket.cpp:191] handleRequest(): [psychic] Got packet with message: TheMessage
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
#0  0x40111ae9:0x3ffd66d0 in httpd_sess_get at /esp_http_server/src/httpd_sess.c:173
#1  0x40112e19:0x3ffd6720 in httpd_ws_get_fd_info at /esp_http_server/src/httpd_ws.c:521
#2  0x400dba35:0x3ffd6740 in PsychicWebSocketHandler::handleRequest(PsychicRequest*) at .pio/libdeps/esp32-wroom/PsychicHttp/src/PsychicWebSocket.cpp:204 (discriminator 7)
#3  0x400dc0b9:0x3ffd6810 in PsychicEndpoint::requestCallback(httpd_req*) at .pio/libdeps/esp32-wroom/PsychicHttp/src/PsychicEndpoint.cpp:72
#4  0x401115b5:0x3ffd6890 in httpd_req_new at /esp_http_server/src/httpd_parse.c:776
#5  0x40111e2e:0x3ffd6930 in httpd_sess_process at /esp_http_server/src/httpd_sess.c:419 (discriminator 15)
#6  0x4010fb9c:0x3ffd6950 in httpd_process_session at /esp_http_server/src/httpd_main.c:178
    (inlined by) httpd_process_session at /esp_http_server/src/httpd_main.c:163
#7  0x4016e03a:0x3ffd6970 in httpd_sess_enum at /esp_http_server/src/httpd_sess.c:50 (discriminator 1)
#8  0x40110c40:0x3ffd6990 in httpd_server at /esp_http_server/src/httpd_main.c:228
    (inlined by) httpd_thread at /esp_http_server/src/httpd_main.c:250

The unmodified PlatformIO example (https://github.com/hoeken/PsychicHttp/tree/master/examples/websockets), on the other hand, works without any problems.

@playmiel
Copy link

I did a search in the code and in http idf to find the source of the problem but I couldn't find any ideas?

@T94T
Copy link
Author

T94T commented Feb 1, 2024

Thank you for looking into it. We have not found a solution either.

@johnnytolengo
Copy link

Take a look on the heap memory to be sure that's not full.

@playmiel
Copy link

playmiel commented Feb 2, 2024

I haven't been able to test it yet, but it's probably due to the "CORE_DEBUG_LEVEL=5" that I'd have to change to "CORE_DEBUG_LEVEL=2" or even less to fix the problem. Can you test it? (notably quoted here #65 )

@T94T
Copy link
Author

T94T commented Feb 14, 2024

Just tried the CORE_DEBUG_LEVEL=2 setting and it does not crash anymore.
On the other hand server.config.stack_size = 8192; has no effect and will still cause a core panic.

@T94T
Copy link
Author

T94T commented Apr 26, 2024

related to: #74

@hoeken
Copy link
Owner

hoeken commented Aug 10, 2024

I think this is fixed, please re-open if necessary.

@hoeken hoeken closed this as completed Aug 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants