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.

CC3235MODSF: Making HTTP Header Larger

Part Number: CC3235MODSF

Using a device authentication token in our API.  The size of the token is around 1200 bytes.

Here are some results when attempting to make the HTTP header larger for the device authentication token:

 

  1. copy http.h, httpclient.c, httpclient.h, httpclient_internal.h to CCS project as recommended.

HTTPClient_connect2 returns error code -370

 

  1. modify HTTPClient_BUF_LEN to 2048 in httpclient_internal.h and rebuild library

HTTPClient_connect2 does not return and program there is a NMI crash.  Possible stack overflow?

 

  1. modify HTTPClient_BUF_LEN to 1408 in httpclient_internal.h and rebuild library

HTTPClient_connect2 returns error code -2006

 

  1. modify HTTPClient_BUF_LEN back to the original value of 256 in httpclient_internal.h and rebuild library

HTTPClient_connect2 returns error code 0 and successful connection to BD host application (Gateway)

  • The -370 is related to the HTTPIF_SetSecMethod. From some reason when using this we try to use TLV1.0 and get rejected by the server. I'll need to check what is the issue here.

    If you avoid this - it will connect successfully (using TLS1.2).

    The Connect2() is not dependent on the HTTPClient_BUF_LEN so should pass anyway.

    The impact of the buffer size will be when you'll call HTTPClient_sendRequest.

    If you increase the HTTPClient_BUF_LEN you should increase the stack size of the "httpTask" as the buffer is allocated on the stack(!!).

    See  TASK_STACK_SIZE in "platform.c".

  • I am setting TLS1.2 using SlNetSock_secAttribSet() so I am not sure why it trying to something else.

    Also, earlier this morning I though about the stack size and I modified TASK_STACK_SIZE to 4096 and HTTPClient_BUF_LEN to 2048 in httpclient_internal.h and rebuild library

    HTTPClient_connect2 returns error code -3008

  • There seems to be a problem in the SlNetSock_secAttribSet(SLNETSOCK_SEC_ATTRIB_METHOD) - for now don't use it. The default will be TLS1.2.

    if you update the stack size, you will need to also update the heap (this can be done by updating linker cmd file if you are using TIRTOS, else you should update the FreeRTOSConfig.h).

  • I disabled the call to  SlNetSock_secAttribSet(SLNETSOCK_SEC_ATTRIB_METHOD) and HTTPClient_connect2 still returns error code -3008.

  • the -3008 is the HTTPClient_EBODYBUFSMALL. 

    Are you still using the 2KB buffer size?

    I was able to pass that with the debug code you provided to me.

  • Yes, I am using the 2KB buffer size.  If I change the buffer back to 256 bytes (only change) I can connect the host and get a response.

  • have you updated the heap size?

  • Yes, I modified the head size to 7000KB in cc32xxxsf_tirtos.cmd.  Also, I misstated something earlier, it is not HTTPClient_connect2() but rather HTTPClient_readResponseBody() that is returning error code -3008..

  • Yes, i figured that is the case.

    you may need to increase the HTTP_MIN_RECV (the data buffer size) you pass to  HTTPClient_readResponseBody.

    If you can step into the HTTPClient_readResponseBody - you should be able to find the root cause.

    (if needed - copy httpclient.c to your project as we discussed yesterday - which can help in the debug process).

  • I am now getting HTTP response status code 401 Unauthorized.  However, if I attempt the same request using Curl or Postman, I get the expected response.  It appears that the token may not being sent properly.  I am going to set up WireShark to verify that the device token that the token is being sent properly.

  • you can use an http dump server to compare the content of the requests.

  • http dump shows that the keyword "Bearer" was missing in the HTTP header.  Looks like the call to HTTPClient_setHeader with HTTPClient_HFIELD_REQ_AUTHORIZATION and the token string does not add the keyword to the HTTP header but instead simply stores the token string and sends it.  

  • right. you the app-token should include the "Bearer " as a prefix.

    You can check the ota_if_dropbox.c in the mqtt_client example:

        #define APP_TOKEN "Bearer " DROPBOX_USER_TOKEN

    (this works with static user token, in your case it it should be part of the Token buffer).

    Please let us know if it works with the fix.