You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a bug in the code. After all the operations are successful, the execution flows into the unlock_and_return label which incorrectly returns ESP_FAIL.
The fix is simple, here it is
intesp_websocket_client_send_with_opcode(esp_websocket_client_handle_tclient, ws_transport_opcodes_topcode, constuint8_t*data, intlen, TickType_ttimeout)
{
interror=ESP_OK;
if (client==NULL||len<0|| (data==NULL&&len>0)) {
ESP_LOGE(TAG, "Invalid arguments");
returnESP_FAIL;
}
if (xSemaphoreTakeRecursive(client->lock, timeout) !=pdPASS) {
ESP_LOGE(TAG, "Could not lock ws-client within %"PRIu32" timeout", timeout);
returnESP_FAIL;
}
if (!esp_websocket_client_is_connected(client)) {
ESP_LOGE(TAG, "Websocket client is not connected");
error=ESP_FAIL;
goto unlock_and_return;
}
if (client->transport==NULL) {
ESP_LOGE(TAG, "Invalid transport");
error=ESP_FAIL;
goto unlock_and_return;
}
if (esp_websocket_new_buf(client, true) !=ESP_OK) {
ESP_LOGE(TAG, "Failed to setup tx buffer");
error=ESP_FAIL;
goto unlock_and_return;
}
if (esp_websocket_client_send_with_exact_opcode(client, opcode | WS_TRANSPORT_OPCODES_FIN, data, len, timeout) != true) {
ESP_LOGE(TAG, "Failed to send the buffer");
error=ESP_FAIL;
goto unlock_and_return;
}
unlock_and_return:
xSemaphoreGiveRecursive(client->lock);
returnerror;
}
The text was updated successfully, but these errors were encountered:
github-actionsbot
changed the title
esp_websocket_client_send_with_opcode returns ESP_FAIL even if send is successful
esp_websocket_client_send_with_opcode returns ESP_FAIL even if send is successful (IDFGH-11290)
Oct 23, 2023
Answers checklist.
General issue report
esp_websocket_client_send_with_opcode in https://github.com/espressif/esp-protocols/blob/3e8de3af3a8bda2c1b0b1eb3e20c277fe123c40a/components/esp_websocket_client/esp_websocket_client.c#L1201C5-L1201C42 always returns
ESP_FAIL
This is a bug in the code. After all the operations are successful, the execution flows into the
unlock_and_return
label which incorrectly returns ESP_FAIL.The fix is simple, here it is
The text was updated successfully, but these errors were encountered: