cancel
Showing results for 
Search instead for 
Did you mean: 

LWIP - TCP connections are never closed

Tommaso De Gennaro
Associate III
Posted on February 01, 2018 at 17:55

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

#tcp #lwip
1 ACCEPTED SOLUTION

Accepted Solutions
Tommaso De Gennaro
Associate III
Posted on February 08, 2018 at 09:46

Hello,

I solved the problem by switching to LWIP 2.0.3, supported by the STM32CubeMX 4.24.

Best regards

Tommaso

View solution in original post

1 REPLY 1
Tommaso De Gennaro
Associate III
Posted on February 08, 2018 at 09:46

Hello,

I solved the problem by switching to LWIP 2.0.3, supported by the STM32CubeMX 4.24.

Best regards

Tommaso