2025-10-07 8:37 PM
Hello, I am using the x-nucleo-67W61M1 and the supported STM32N6 nucleo and I run the HTTPS Server application. The sample works well. I want to transfer loads of data and I do it through cJSON. I understand that i need to set a different get command and add an if statement in the HTTP_process_response that will handle the request and it will respond accordingly. I have set also a script in Matlab that does continuous gets and after a while i see that the STM is stuck and is no longer responding (I have the LEDs toggling in a different RTOS task) the log when that happens is:
[ERROR] [114031] [HTTP_00000001] (w61_at_net.c:441) W61_AT_SetExecute: W61_STATUS_TIMEOUT. It can lead to unexpected behavior.
[ERROR] [114031] [HTTP_00000001] (httpserver.c:524) [1] *****> SEND ERROR <*****
[ERROR] [116031] [HTTP_00000001] (w61_at_net.c:351) W61_AT_SetExecute: W61_STATUS_TIMEOUT. It can lead to unexpected behavior.
[ERROR] [118033] [defaultTask] (w61_at_net.c:1130) W61_Net_GetSocketInformation: W61_STATUS_TIMEOUT (no response). It can lead to unexpected behavior
Creation of temporary thread to process an incoming HTTP request : 2
[ERROR] [119037] [HTTP_00000002] (httpserver.c:446) No data read on the socket, closing the socket
[ERROR] [120033] [HTTP_00000001] (w61_at_net.c:351) W61_AT_SetExecute: W61_STATUS_TIMEOUT. It can lead to unexpected behavior.My code inside the http_process_response is:
else if(response == DATA_STATE){
cJSON_Hooks hooks =
{
.malloc_fn = pvPortMalloc,
.free_fn = vPortFree,
};
cJSON_InitHooks(&hooks);
cJSON *root = cJSON_CreateObject();
{
cJSON *skills = cJSON_CreateArray();
cJSON_AddItemToObject(root, "segments", skills);
for(int i = 0; i < 1; i++){
cJSON *segment = cJSON_CreateObject();
cJSON_AddItemToArray(skills, segment);
cJSON_AddItemToObject(segment, "v1", cJSON_CreateString("3112"));
cJSON_AddItemToObject(segment, "v2", cJSON_CreateString("3113"));
cJSON_AddItemToObject(segment, "v3", cJSON_CreateString("3114"));
cJSON_AddItemToObject(segment, "v4", cJSON_CreateString("3115"));
cJSON_AddItemToObject(segment, "v5", cJSON_CreateString("3116"));
cJSON_AddItemToObject(segment, "v6", cJSON_CreateString("3117"));
cJSON_AddItemToObject(segment, "v7", cJSON_CreateString("3118"));
cJSON_AddItemToObject(segment, "v8", cJSON_CreateString("3119"));
cJSON_AddItemToObject(segment, "v9", cJSON_CreateString("3120"));
cJSON_AddItemToObject(segment, "v10", cJSON_CreateString("3121"));
cJSON_AddItemToObject(segment, "v11", cJSON_CreateString("3122"));
cJSON_AddItemToObject(segment, "v12", cJSON_CreateString("3123"));
cJSON_AddItemToObject(segment, "t1", cJSON_CreateString("3110"));
cJSON_AddItemToObject(segment, "t2", cJSON_CreateString("3111"));
cJSON_AddItemToObject(segment, "t3", cJSON_CreateString("3112"));
cJSON_AddItemToObject(segment, "t4", cJSON_CreateString("3113"));
cJSON_AddItemToObject(segment, "t5", cJSON_CreateString("3114"));
cJSON_AddItemToObject(segment, "t6", cJSON_CreateString("3115"));
cJSON_AddItemToObject(segment, "t7", cJSON_CreateString("3116"));
cJSON_AddItemToObject(segment, "t8", cJSON_CreateString("3117"));
cJSON_AddItemToObject(segment, "t9", cJSON_CreateString("3118"));
cJSON_AddItemToObject(segment, "t10", cJSON_CreateString("3119"));
}
}
char *ret = cJSON_PrintUnformatted(root);
cJSON_Delete(root);
snprintf(&response_template[strlen(response_template)], sizeof(response_template) - strlen(response_template),"Content-Length: %" PRIu32 "\r\n\r\n%s", (uint32_t)strlen(ret), ret);
currentResponse++;
response_data = response_template;
}I think there is something going with the memory management, because when I change the response_template size to 1024 (or more but after 2048 it freezes in the first callback) it shows more of the data that wouldn't fit normally, but seems to fails more. also changing the HTTP_CHILD_TASK_STACK_SIZE seemed to affect it. I have increased the total heap of the RTOS and the specific heap of the task.
Another question I have is how can i send the data inn multiple steps, that may be the solution to my problem.
Any help is welcome,
Thanks in advance
Solved! Go to Solution.
2025-10-28 2:42 AM
Hello Louis
Thanks for the answer.
What helped me solve this problem was multiple things:
First of all I disabled all the debug messages.
Then I did the multiple step server write function which seemed to help but not eliminate the problem
And final in the response template I changed the Content-Type to application/json. After that change it never seemed to get stuck again.
Thanks again for the response,
Dimitris
2025-10-28 1:57 AM
Hello Dimitris_Kara,
Indeed, you must size the HTTP_CHILD_TASK_STACK_SIZE and the response_template to match your requirements. The code provided in httpserver.c is only an example code, sized for the needs of the application provided.
The data could be already sent in multiple steps in the http_server_write function.
If the data to send is bigger than the SPI maximum transmission unit, it will be automatically limited to this value. After that the send command will return the number of bytes actually sent.
That is why you have to loop on this command to send the total length of your buffer.
You could imagine adding another loop above, to fragment even more your payload if you want, even if I'm not sure this will solve your issue.
Let me know if this help!
Regards
Louis
2025-10-28 2:42 AM
Hello Louis
Thanks for the answer.
What helped me solve this problem was multiple things:
First of all I disabled all the debug messages.
Then I did the multiple step server write function which seemed to help but not eliminate the problem
And final in the response template I changed the Content-Type to application/json. After that change it never seemed to get stuck again.
Thanks again for the response,
Dimitris