HTTP client connection fails while sending multiple file data

snehapawar#
Posts: 22
Joined: Wed Jan 13, 2021 1:11 pm

HTTP client connection fails while sending multiple file data

Postby snehapawar# » Mon Sep 12, 2022 2:04 pm

Hi All,

We are getting a issue while sending files data using http client connection using ESP32S3 chip.
HTTP gets disconnected after sending 10 file's data successfully. It takes 12-14 secs nearly a just before disconnection of HTTP.

What we want to do is, we need to send more number of files, saved in the device in one go without getting disconnected. We can hardly send 10 files data, and http connection gets disconnected.

Things we tried:
1. Tried increasing the number of Wi-Fi RX buffers from 10 to 16 but the result is same and also it is decreasing the available RAM.
2. Tried Persistent connections example mentioned in https://docs.espressif.com/projects/esp ... lient.html. Tried increasing the Provisioning auto-stop timeout setting in menu config. Default value is 30 seconds and I tried increasing it to 2 min.

- We didn't get any positive results with the above trails.

Please do let me know if there is any other solution for which I can send huge number of data packets at the same time without getting the HTTP disconnected?



PFA logs below:

E (37757) esp-tls: Failed to create socket (family 2 socktype 1 protocol 0)
E (37757) TRANSPORT_BASE: Failed to open a new connection: 32770
E (37767) HTTP_CLIENT: Connection failed, sock < 0
I (37777) HTTP: HTTP_EVENT_DISCONNECTED
I (37777) HTTP: Last esp error code: 0x8002
I (37787) HTTP: Last mbedtls failure: 0x0
E (37787) esp-tls: Failed to create socket (family 2 socktype 1 protocol 0)
E (37797) TRANSPORT_BASE: Failed to open a new connection: 32770
E (37807) HTTP_CLIENT: Connection failed, sock < 0
HTTP: HTTP POST request failed: ESP_ERR_HTTP_CONNECT







datasheet mentioned ESP_ERR_ESP_TLS_CANNOT_CREATE_SOCKET (0x8002): Failed to create socket



Please find the patch we are using for this:


//*****************************************************************************************************************//
bool wifi_send_by_HTTP(const char* url,const char* post_data){


char RECEIVE_BUFFER[MAX_HTTP_OUTPUT_BUFFER] = {};

// printf("wifi: url %s\r\n", url);
char local_response_buffer[MAX_HTTP_OUTPUT_BUFFER] = {0};
/**
* NOTE: All the configuration parameters for http_client must be spefied either in URL or as host and path parameters.
* If host and path parameters are not set, query parameter will be ignored. In such cases,
* query parameter should be specified in URL.
*
* If URL as well as host and path parameters are specified, values of host and path will be considered.
*/
esp_http_client_config_t config = {
.host = "httpbin.org",
.path = "/get",
.event_handler = _http_event_handler,
.user_data = local_response_buffer, // Pass address of local buffer to get response
.disable_auto_redirect = false, //true,
};
esp_http_client_handle_t client = esp_http_client_init(&config);

// POST
esp_http_client_set_url(client, url);
esp_http_client_set_method(client, HTTP_METHOD_POST);
esp_http_client_set_header(client, "Content-Type", "application/json"); //"text/plain");
esp_http_client_set_post_field(client, post_data, strlen(post_data));
esp_err_t err = esp_http_client_perform(client);
if (err == ESP_OK) {
uint32_t data_length = esp_http_client_get_content_length(client);
_log("HTTP: HTTP POST Status = %d, content_length = %d",
esp_http_client_get_status_code(client),
data_length);


memcpy(RECEIVE_BUFFER,local_response_buffer,data_length);
memset(local_response_buffer,0,MAX_HTTP_OUTPUT_BUFFER);



.
.
.
.
.
.
.
.
.
.


}



Please let me know how to resolve this issue

Who is online

Users browsing this forum: No registered users and 39 guests