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.

RTOS: EK-TM4C129EXL | HTTPServer - Can't Recieve large payload

Tool/software: TI-RTOS

Hello,

I have a problem with http server. I would like to POST JSON with size larger than 1135 I always get the following response:

<html>
    <body>
        <h1>HTTP/1.0 400 - Bad Request</h1>
    </body>
</html>

The more data I sent the later I got the above error message. I suppose there must be a limit for the POST, but I dont know where. 

Here is my post handler but it never runs and the argument 'buff' is allocated in the EPI ram with enough size.

static cJSON * http_readReq(SOCKET s, int len, char * buff, size_t buffLen, int * c) {
	// clear buff
	memset(buff, 0, buffLen);

	// its a GET req
	if(!len) {*c = HTTP_CODE_OK; return NULL;}

	// check buffer sizes
	if(len > buffLen) {*c = HTTP_CODE_REQ_ENTRY_LARGE; return NULL;}

	// try read the whole req. body
	if(recv(s, buff, len, MSG_WAITALL) == len) {

		cJSON * jReq = cJSON_Parse(buff);
		*c = jReq ? HTTP_CODE_OK : HTTP_CODE_BAD_REQUEST;
		return jReq;
	}

	*c = HTTP_CODE_BAD_REQUEST; return NULL;
}

I don't know how to debug the problem, becase the problem should be somewhere in the following function:

efs_createfile("myuri", 0, (uint8_t *)myFxHandler);

I have functions implemented on the board returning large payloads for GET requests, but I can not POST large data. 

Any idea?

  • I have increased the LOW,MID,HIGH task sizes from 1024 to 4096, now it can accept large POST payloads, however the processing time increased. When the payload size is around 1280... the HTTP Server response time is about 50ms, above that value it takes around 2500ms...
  • Daniel Vamos said:
    When the payload size is around 1280... the HTTP Server response time is about 50ms, above that value it takes around 2500ms...

    Are you able to get Wireshark capture in the case where the payload size causes the response time to be around 2500ms?

    If you haven't applied the fix for TIDRIVERS-368 as linked on Networking on TM4C129 Devices, then if the large POST request initially causes the maximum size packet is sent to the Tiva device, a possible effect of the TIDRIVERS-368 bug is that the maximum size packet may be dropped causing the sender to retry with smaller packets after a delay.

  • Hello,

    I have attached 2 captures from a smaller and a larger request. I have read the thread in that you linked but I am still not sure what to do in order to resolve this problem.


  • Daniel Vamos said:
    I have attached 2 captures from a smaller and a larger request.

    The 2nd capture for the larger request shows two packets with the maximum length of 1514 apparently not being received by the TivaC device (assumed to be IP address 192.168.0.66) before the post completes with smaller size packets. This results in an overall post duration of around 2300ms. This is a sign you are being affected by bug TIDRIVERS-368.

    Daniel Vamos said:
    I have read the thread in that you linked but I am still not sure what to do in order to resolve this problem.

    Download the 1033.tcpEcho_EK_TM4C1294XL_TI_TivaTM4C1294NCPDT.zip project which is attached to RTOS/EK-TM4C1294XL: NDK in TI-RTOS for TivaC 2.16.1.14 can get into a state where unable to transmit packets. Copy the EMACSnow.c from the zip file and add to your project, and then recompile. This includes the fix for TIRTOS-1488 as well as TIDRIVERS-368.

    This is a quick change which places the modified EMACSnow.c EMAC driver from TI-RTOS for TivaC into your project, without having to re-build the TI-RTOS libraries. If you have multiple projects which use TI-RTOS, you could instead replace the EMACSnow.c inside the TI-RTOS installation, and then rebuild TI-RTOS.

  • Thank you very much for your help!!!
  • Daniel Vamos said:
    Is there any way to provide a buffer and process the tcp packets into a user provided buffer as HTTPClient does? What is the recommended way?

    I haven't created a HTTP server using the TI-RTOS NDK / NS myself, so not sure at the moment.

    Can you explain how the http_readReq function gets called from the myFxHandler function registered with the call to efs_createfile?

    Looking at tirtos_tivac_2_16_00_08 which uses ns_1_11_00_10 I can't see the definition of the cJSON structure which is used by your http_readReq function.

    Edit: The post I was replying to seems to have been removed from the thread.

  • Dear Chester,

    By the time, I was able to eliminate the problem. For first look, I thouth that it is related to the HTTP server but later it was the SysMin.Buffer size issue. That's why I removed my previous post.

    Thank you for your reply.