This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3220SF: How to set timeout for HTTPClient_connect

Part Number: CC3220SF

Hi guys,

I'm using the your module httpclient to send some HTTP requests.

Is there a way to set a custom timeout for the APIs HTTPClient_connect() and HTTPClient_sendRequest()?

What is the default timeout?

Regards

Lorenzo

  • Hi Lorenzo,

    For HTTPClient_connect(), there is no way to alter the timeout of the underlying TCP socket connect() call. This is fixed at ~10 seconds. You could edit the HTTP client library code to make that TCP socket non-blocking, but it would still result in a delayed timeout error returned to your socket callback after the timeout expires.

    For HTTPClient_sendRequest(), there is also no way to directly implement a timeout. HTTPClient_sendRequest() performs send() calls as needed, and adding a timeout to the send() calls is not possible. You can only specify timeouts for recv() calls, as send() calls shouldn't be blocking in your application for any appreciable amount of time anyway given that function simply passes the send buffer to the NWP to process. Like the TCP connect function, send() has a hardcoded timeout of sorts based on TCP retries. If the TCP packets sent are not acked back after a fixed number of retries then an error will be returned from send(). This behavior cannot be modified. If you are concerned with the HTTP requests taking too long to send data while trying to send a very large request, you can implement an application timeout based on a timer where you check the system time after every send() to see if you're taking too long. There is however no method to set this through an API, you will need to edit the HTTPClient_sendRequest() function in the library to implement this yourself.

    Let me know if you need more clarification on these TCP timeouts or if you have further questions on using the HTTPClient library.

    Regards,
    Michael
  • Hi Michael,
    Is this timeout (fixed at 10 seconds) defined in the stack of the sdk or in NWP code? Can I change this value by a rebuild of the HTTPClient library? If I can modify this timeout value, can you indicate to me what is the define that I have to change and explain to me the steps that I have to do in order to rebuild the HTTPClient library?

    Regards

    Lorenzo
  • Hi Lorenzo,

    This TCP timeout is fixed in the NWP code. It cannot be changed by any application code that you can execute on the MCU.

    Regards,
    Michael