-
Notifications
You must be signed in to change notification settings - Fork 433
FR: Allow configuring LwIP's keepalives #114
Comments
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
It's a bit hacky, but you can enable keepalive adding these lines pcb->so_options |= SOF_KEEPALIVE; //Turn on TCP Keepalive for the given pcb
// Set the time between keepalive messages in milli-seconds
pcb->keep_idle = 45000; // 45 seconds
pcb->keep_intvl = 45000; // 45 seconds
pcb->keep_cnt = 7; //The number of unanswered probes required to force closure of the socket
// printf("keep alive is on"); //low level debug only after here: Line 1318 in ca8ac5f
|
[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future. |
@copercini big thanks, I'll try to make my own fork with this! |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions. |
Hi.
Is it possible to add support for TCP keepalives (and methods to enable/disable/configure them)? As I understand, LwIP has this functionality and it can be enabled on per-socket basis (I just don't know if it's compiled into ESP32 core).
You see, it's not uncommon in embedded world to just unplug the device from power, in this case a TCP connection will be hanging on the other side and some non-trivial logic would be required to detect and close it. I am testing an application with AsyncServer on one ESP32 and long-lasting TCP connection to WiFiClient on other ESP32, and this ESP32 can be unplugged from power without proper termination. In this case I don't see a
onDisconnect
called on server side, as well as no events (timeouts, errors) that could help in detecting broken connection. The only approach at the moment is to write my own keep-alive logic, but that would be so cumbersome, not to mention changes in upper-level protocol.Might be useful: https://stackoverflow.com/questions/29492995/lwip-stack-netconn-api-keep-connection-keep-alive
The text was updated successfully, but these errors were encountered: