Skip to content

fix Stuck when ‘disable_auto_reconnect = false’ and Call 'esp_websocket_client_close' when the connection fails and automatically reconnects (IDFGH-15854) #841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions components/esp_websocket_client/esp_websocket_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,7 @@ static int esp_websocket_client_send_close(esp_websocket_client_handle_t client,

static esp_err_t esp_websocket_client_close_with_optional_body(esp_websocket_client_handle_t client, bool send_body, int code, const char *data, int len, TickType_t timeout)
{
int err = ESP_OK;
if (client == NULL) {
return ESP_ERR_INVALID_ARG;
}
Expand All @@ -1236,9 +1237,13 @@ static esp_err_t esp_websocket_client_close_with_optional_body(esp_websocket_cli
}

if (send_body) {
esp_websocket_client_send_close(client, code, data, len + 2, portMAX_DELAY); // len + 2 -> always sending the code
err = esp_websocket_client_send_close(client, code, data, len + 2, portMAX_DELAY); // len + 2 -> always sending the code
} else {
esp_websocket_client_send_close(client, 0, NULL, 0, portMAX_DELAY); // only opcode frame
err = esp_websocket_client_send_close(client, 0, NULL, 0, portMAX_DELAY); // only opcode frame
}
if (err != ESP_OK) {
ESP_LOGW(TAG, "Client was not connected");
return ESP_FAIL;
}

// Set closing bit to prevent from sending PING frames while connected
Expand Down