Network netconn_recv() hangs after multiple requests
Posted: Tue Oct 24, 2023 8:07 am
I have the following FreeRTOS task that processes TCP connection requests. It is hanging randomly. After debugging I found that the netconn_recv function is no longer receiving the requests and blocks, even when there is data to be processed.
Does anyone have any idea what could be causing the issue.
Does anyone have any idea what could be causing the issue.
Code: Select all
#define TCP_BUF_LEN 1024
void networkTask(void)
{
uint16_t receivebuf_len = 0;
char receivebuf[TCP_BUF_LEN] = {0};
char transmitbuf[TCP_BUF_LEN] = {0};
struct netconn* conn = globalScope.conn;
struct netbuf *inbuf;
err_t err = ERR_OK;
while(err == ERR_OK)
{
// read request
err = netconn_recv(conn, &inbuf);
if(err != ERR_OK)
{
ESP_LOGE(TAG, "error");
break;
}
receivebuf_len = netbuf_copy(inbuf, receivebuf, TCP_BUF_LEN);
processRequest(receivebuf, receivebuf_len);
// write response
processResponse(transmitbuf);
netconn_write(conn, transmitbuf, strlen(transmitbuf), NETCONN_COPY);
netbuf_free(inbuf);
netbuf_delete(inbuf);
vTaskDelay(10);
}
netconn_close(conn);
netconn_delete(conn);
}