mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 11:03:11 +00:00
3d0e26170d
PONG frames (opcode 0xA) were never dispatched to the user's WebSocket handler despite an existing comment stating they should be. The dispatch condition `ra->ws_type < HTTPD_WS_TYPE_CLOSE` excluded PONG (0xA) since CLOSE is 0x8. This caused a critical secondary bug: when the server sends PING frames and the client responds with PONG, httpd_ws_recv_frame() is never called for the PONG, leaving the remaining frame bytes (second_byte plus 4-byte mask_key) unconsumed in the TCP buffer. On the next WebSocket read, these orphaned bytes are misinterpreted as a new frame header, causing either "WS frame is not properly masked" errors or EAGAIN timeouts with garbage length values, effectively destroying the connection. Add `ra->ws_type == HTTPD_WS_TYPE_PONG` to the dispatch condition so PONG frames reach the user handler, which calls httpd_ws_recv_frame() to properly consume the frame bytes from the socket. Closes https://github.com/espressif/esp-idf/issues/18227