AnsweredAssumed Answered

LWIP - TCP connections are never closed

Question asked by Tommaso De Gennaro on Feb 1, 2018
Latest reply on Feb 8, 2018 by Tommaso De Gennaro

Hello,
I am developing a client-server system using an STM32F407 CPU.

 

The client is a VB.net software that sends some commands to the server, opening and closing a TCP socket for every commands.

 

To develop server firmware I'm modifing the "TCP Echo Server" example based on Raw API.

 

The system works perfectly, provided that the data sent by the client (command and parameters) is a maximum of 12 bytes long; if the data is longer, it appears that the TCP connection is never really closed by the server.

 

Infact, if the number of the simultaneously active TCP connections (setted with the parameter MEMP_NUM_TCP_PCB in lwipopts.h) is five, by sending sequentially five commands the server answers yet, but if another commands is sent next, it goes down and I get the following messages from the LWIP logs:

 

memp_malloc: insufficient memory in the TCP_PCB pool
tcp_alloc: delete the oldest TIME-WAIT connection
memp_malloc: insufficient memory in the TCP_PCB pool
tcp_alloc: killing of the oldest LAST-ACK connection
memp_malloc: insufficient memory in the TCP_PCB pool
tcp_alloc: delete the oldest CLOSING connection
memp_malloc: insufficient memory in the TCP_PCB pool
tcp_alloc: killing of the connection with prio less than 64
memp_malloc: insufficient memory in the TCP_PCB pool
tcp_listen_input: unable to allocate PCBs

 

That seems to mean that the LWIP cannot create a new connection because the limit is reached.

 

I tried to change the other parameters in the lwipopts.h file, such as the heap memory size (MEM_SIZE) or the memp struct pbufs number (MEMP_NUM_PBUF), but I still get the same error.

 

Please, could you give me some suggestions to solve the problem?

 

Best Regards,

Tommaso

Outcomes