How to prevent http request from blocking task for too long?
Posted: Mon Nov 19, 2018 10:54 pm
Hi all,
I'm using esp_http_client to make requests to a server. However, when the server is down, the http request is blocking the rest of the task for a very long time.
I want to make it so that if the server is offline and the client can't post, it should immediately stop. Is this possible to do? I tried to change this using the "timeout_ms" parameter in the configuration struct as below:
The code to use client just sets the post data and calls as normal.
After this change, the client still attempts the connection for too long. I thought setting ".timeout_ms" would make the client stop blocking after 50ms, but perhaps I misunderstood. Any way to make this happen?
Thanks!
I'm using esp_http_client to make requests to a server. However, when the server is down, the http request is blocking the rest of the task for a very long time.
I want to make it so that if the server is offline and the client can't post, it should immediately stop. Is this possible to do? I tried to change this using the "timeout_ms" parameter in the configuration struct as below:
Code: Select all
esp_http_client_config_t post_config = {
.url = ip_url,
.event_handler = post_handler,
.timeout_ms = 50,
};
post_client = esp_http_client_init(&post_config)
Code: Select all
esp_http_client_perform(post_client)
After this change, the client still attempts the connection for too long. I thought setting ".timeout_ms" would make the client stop blocking after 50ms, but perhaps I misunderstood. Any way to make this happen?
Thanks!