fix(websocket): avoid long stop time when waiting to auto-reconnect (IDFGH-14393) #729
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This fixes an issue that occurred when auto-reconnection is enabled, and the client is disconnected from the server. In this situation, if the
esp_websocket_client_stop()
method is called, the caller could remain stuck waiting for a maximum time equal to half ofreconnect_timeout_ms
.This fix allows the
esp_websocket_client_task
to be woken up when it is waiting to reconnect, so it can be closed promptly when requested byesp_websocket_client_stop()
.Testing
Procedure:
disable_auto_reconnect = false
andreconnect_timeout_ms = 180000
WEBSOCKET_STATE_WAIT_TIMEOUT
, callesp_websocket_client_stop()
Before these changes, the
esp_websocket_client_stop()
method could remain stuck for up to 90000 ms, half ofreconnect_timeout_ms
. With the implementation of this fix, the internal client task is woken up and stoppedChecklist
Before submitting a Pull Request, please ensure the following: