Page 1 of 1

esp_http_client_close(client) returns FAIL

Posted: Thu Dec 31, 2020 7:44 am
by kubera
Hi,
I was trying to implement file uploading using the native method. I am able to upload the files without any problem but after the upload when I am trying to close the connection, it always returns FAIL.

Code: Select all

    err = esp_http_client_close(client);
    if (err != ESP_OK)
    {
        ESP_LOGE(TAG, "Failed to close HTTP connection: %s", esp_err_to_name(err));
        esp_http_client_cleanup(client);
    }


Can anybody point me out why is it happening so?

Re: esp_http_client_close(client) returns FAIL

Posted: Thu Dec 31, 2020 10:39 am
by boarchuz
The server may have already closed the connection after completing the response. You can disregard the return value of esp_http_client_close for your purposes here - either it closes and returns OK, or it's already closed and you get some other code.

Code for the full request would be useful if I'm off the mark.