Connection (socket) not closed when connection is lost #1662
-
I am using Mongoose v7.6 on an embedded device running FreeRTOS and LwIP. The device is a web server and is using a wifi connection and it is connected to an access point. If I am connected to the device with a client and close the browser on the client, I see that some connections are closed, but if I switch off for example the access point, and then I lost the wifi connection, I cannot see that any connection has been closed on Mongoose. I try to detect the lost of wifi connection and call mg_mgr_free(), but it seems that after some sockets that are closed, lwip is blocked on the lwip_close(). any idea ? Socket connections should not be closed when the connection has been lost ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
When you close your client, it clearly sends a closure indication (FIN). If you unplug your client's network cable, the server won't notice until a TCP keep-alive timer expires. If you power off your AP on a WiFi server... well, TCP won't notice until keep-alive timer expires; but you should have some way of detecting link status if that is important to you. Check your vendor implementation, lwIP's netif reference is here. You should not call mg_mgr_free() right away but close your connections first. |
Beta Was this translation helpful? Give feedback.
-
It looks like the old connections got stalled - maybe TCP keep-alive does not work? |
Beta Was this translation helpful? Give feedback.
When you close your client, it clearly sends a closure indication (FIN).
If you unplug your client's network cable, the server won't notice until a TCP keep-alive timer expires.
If you power off your AP on a WiFi server... well, TCP won't notice until keep-alive timer expires; but you should have some way of detecting link status if that is important to you. Check your vendor implementation, lwIP's netif reference is here.
You should not call mg_mgr_free() right away but close your connections first.