Skip to content

Commit 8add487

Browse files
committed
fix(websocket): prevent connection abort on write timeout
1 parent 25513d0 commit 8add487

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

components/esp_websocket_client/esp_websocket_client.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,12 @@ static int esp_websocket_client_send_with_exact_opcode(esp_websocket_client_hand
669669
wlen = esp_transport_ws_send_raw(client->transport, opcode, (char *)client->tx_buffer, need_write,
670670
(timeout == portMAX_DELAY) ? -1 : timeout * portTICK_PERIOD_MS);
671671
if (wlen < 0 || (wlen == 0 && need_write != 0)) {
672+
if (wlen == 0 && timeout != portMAX_DELAY && errno == 0) {
673+
// Timeout, stop sending and return what we have
674+
ret = widx;
675+
esp_websocket_free_buf(client, true);
676+
goto unlock_and_return;
677+
}
672678
ret = wlen;
673679
esp_websocket_free_buf(client, true);
674680
esp_tls_error_handle_t error_handle = esp_transport_get_error_handle(client->transport);

0 commit comments

Comments
 (0)