diff --git a/components/esp_websocket_client/esp_websocket_client.c b/components/esp_websocket_client/esp_websocket_client.c index f943a86895..2e937f5d2a 100644 --- a/components/esp_websocket_client/esp_websocket_client.c +++ b/components/esp_websocket_client/esp_websocket_client.c @@ -1044,12 +1044,6 @@ static void esp_websocket_client_task(void *pv) break; } client->ping_tick_ms = _tick_get_ms(); - - if (esp_websocket_client_recv(client) == ESP_FAIL) { - ESP_LOGE(TAG, "Error receive data"); - esp_websocket_client_abort_connection(client, WEBSOCKET_ERROR_TYPE_TCP_TRANSPORT); - break; - } break; case WEBSOCKET_STATE_WAIT_TIMEOUT: @@ -1086,6 +1080,14 @@ static void esp_websocket_client_task(void *pv) xSemaphoreTakeRecursive(client->lock, lock_timeout); esp_websocket_client_abort_connection(client, WEBSOCKET_ERROR_TYPE_TCP_TRANSPORT); xSemaphoreGiveRecursive(client->lock); + } else if (read_select > 0) { + if (esp_websocket_client_recv(client) == ESP_FAIL) { + ESP_LOGE(TAG, "Error receive data"); + xSemaphoreTakeRecursive(client->lock, lock_timeout); + esp_websocket_client_abort_connection(client, WEBSOCKET_ERROR_TYPE_TCP_TRANSPORT); + xSemaphoreGiveRecursive(client->lock); + break; + } } } else if (WEBSOCKET_STATE_WAIT_TIMEOUT == client->state) { // waiting for reconnecting...