Description
When running long-lived TCP/UDP tunnels through NAT firewalls, routers often silently drop idle connections without sending RST packets. This leaves the Latch client or server in a half-open state, hanging indefinitely and consuming worker pool resources. We need an application-level ping-pong mechanism to keep connections alive and detect dead peers quickly.
Proposed Solution
- Frame Definitions: Add custom frame types
PING and PONG to our binary encapsulation protocol.
- Keepalive Ticker: If no data frames have been transmitted or received within an idle interval (e.g., 30 seconds), send a
PING frame.
- Dead Peer Detection (DPD): If a peer fails to reply with a
PONG within a specified timeout (e.g., 10 seconds) after the ping, terminate the connection, clean up state, and return the allocated buffers back to the sync.Pool.
Definition of Done
Description
When running long-lived TCP/UDP tunnels through NAT firewalls, routers often silently drop idle connections without sending
RSTpackets. This leaves the Latch client or server in a half-open state, hanging indefinitely and consuming worker pool resources. We need an application-level ping-pong mechanism to keep connections alive and detect dead peers quickly.Proposed Solution
PINGandPONGto our binary encapsulation protocol.PINGframe.PONGwithin a specified timeout (e.g., 10 seconds) after the ping, terminate the connection, clean up state, and return the allocated buffers back to thesync.Pool.Definition of Done
PINGandPONGframes.