Skip to content

Conversation

PaoloPasinetti
Copy link

@PaoloPasinetti PaoloPasinetti commented Jan 9, 2025

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 of reconnect_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 by esp_websocket_client_stop().

Testing

Procedure:

  1. Start the client using a bad server url/IP, configuring disable_auto_reconnect = false and reconnect_timeout_ms = 180000
  2. When the client is in WEBSOCKET_STATE_WAIT_TIMEOUT, call esp_websocket_client_stop()

Before these changes, the esp_websocket_client_stop() method could remain stuck for up to 90000 ms, half of reconnect_timeout_ms. With the implementation of this fix, the internal client task is woken up and stopped


Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

This commit 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 of wait_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.
@CLAassistant
Copy link

CLAassistant commented Jan 9, 2025

CLA assistant check
All committers have signed the CLA.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Jan 9, 2025
@github-actions github-actions bot changed the title fix(websocket): avoid long waiting time when waiting to auto-reconnect fix(websocket): avoid long waiting time when waiting to auto-reconnect (IDFGH-14393) Jan 9, 2025
@PaoloPasinetti PaoloPasinetti changed the title fix(websocket): avoid long waiting time when waiting to auto-reconnect (IDFGH-14393) fix(websocket): avoid long stop time when waiting to auto-reconnect (IDFGH-14393) Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants