esp_http_client_fetch_headers behaviour
Posted: Wed Nov 21, 2018 2:59 pm
Hi,
I have some code which calls a few functions in this order:
In clientConfig I do not specify a timeout but I have had a look at the code in esp_http_client_init and in that case it should provide a default timeout value of 5000 milliseconds. When the code executes I would expect that calling esp_http_client_fetch_headers will therefore allow up to 5000 milliseconds for the headers to be received.
At least that is what I think it should do when I look at the source code for that function.
However: I have log files from the UART output that clearly show that the output from both the ESP_LOGI calls above occur within the same microsecond.
The really odd thing is that I have several units that consistently report "Reported image length: -1" while others do provide the correct image length value. If I put my own 2 second time delay before calling esp_http_client_fetch_headers it always works OK. It very much looks like the timeout value is ignored but why ?
Any ideas/suggestions much appreciated.
I have some code which calls a few functions in this order:
- httpClient = esp_http_client_init ( &clientConfig );
- ESP_LOGI ( TAG, "httpClient configured and created!");
- espError = esp_http_client_open( httpClient, 0);
- imageLength = esp_http_client_fetch_headers ( httpClient );
- ESP_LOGI ( TAG, "Reported image length: %d ", imageLength );
In clientConfig I do not specify a timeout but I have had a look at the code in esp_http_client_init and in that case it should provide a default timeout value of 5000 milliseconds. When the code executes I would expect that calling esp_http_client_fetch_headers will therefore allow up to 5000 milliseconds for the headers to be received.
At least that is what I think it should do when I look at the source code for that function.
However: I have log files from the UART output that clearly show that the output from both the ESP_LOGI calls above occur within the same microsecond.
The really odd thing is that I have several units that consistently report "Reported image length: -1" while others do provide the correct image length value. If I put my own 2 second time delay before calling esp_http_client_fetch_headers it always works OK. It very much looks like the timeout value is ignored but why ?
Any ideas/suggestions much appreciated.