Skip to content
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