@@ -1063,8 +1063,13 @@ static void esp_websocket_client_task(void *pv)
1063
1063
esp_websocket_client_abort_connection (client , WEBSOCKET_ERROR_TYPE_TCP_TRANSPORT );
1064
1064
}
1065
1065
} else if (WEBSOCKET_STATE_WAIT_TIMEOUT == client -> state ) {
1066
+ // clear any pending notifications
1067
+ ulTaskNotifyTake (pdTRUE , 0 );
1066
1068
// waiting for reconnecting...
1067
- vTaskDelay (client -> wait_timeout_ms / 2 / portTICK_PERIOD_MS );
1069
+ int delay = client -> wait_timeout_ms - (_tick_get_ms () - client -> reconnect_tick_ms );
1070
+ if (client -> run && delay >= 0 ) {
1071
+ ulTaskNotifyTake (pdTRUE , pdMS_TO_TICKS (delay ) + 1 );
1072
+ }
1068
1073
} else if (WEBSOCKET_STATE_CLOSING == client -> state &&
1069
1074
(CLOSE_FRAME_SENT_BIT & xEventGroupGetBits (client -> status_bits ))) {
1070
1075
ESP_LOGD (TAG , " Waiting for TCP connection to be closed by the server" );
@@ -1133,6 +1138,9 @@ esp_err_t esp_websocket_client_stop(esp_websocket_client_handle_t client)
1133
1138
1134
1139
1135
1140
client -> run = false;
1141
+ if (client -> task_handle ) {
1142
+ xTaskNotifyGive (client -> task_handle );
1143
+ }
1136
1144
xEventGroupWaitBits (client -> status_bits , STOPPED_BIT , false, true, portMAX_DELAY );
1137
1145
client -> state = WEBSOCKET_STATE_UNKNOW ;
1138
1146
return ESP_OK ;
@@ -1188,6 +1196,9 @@ static esp_err_t esp_websocket_client_close_with_optional_body(esp_websocket_cli
1188
1196
1189
1197
// If could not close gracefully within timeout, stop the client and disconnect
1190
1198
client -> run = false;
1199
+ if (client -> task_handle ) {
1200
+ xTaskNotifyGive (client -> task_handle );
1201
+ }
1191
1202
xEventGroupWaitBits (client -> status_bits , STOPPED_BIT , false, true, portMAX_DELAY );
1192
1203
client -> state = WEBSOCKET_STATE_UNKNOW ;
1193
1204
return ESP_OK ;
@@ -1312,6 +1323,10 @@ esp_err_t esp_websocket_client_set_reconnect_timeout(esp_websocket_client_handle
1312
1323
1313
1324
client -> wait_timeout_ms = reconnect_timeout_ms ;
1314
1325
1326
+ if (client -> task_handle ) {
1327
+ xTaskNotifyGive (client -> task_handle );
1328
+ }
1329
+
1315
1330
return ESP_OK ;
1316
1331
}
1317
1332
0 commit comments