Skip to content

implement lightweight keepalive and dead peer detection (DPD) frames #12

Description

@itsVentie

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

  • Update frame parser to handle PING and PONG frames.
  • Implement background idle tickers per connection.
  • Write integration tests simulating silent connection drops to verify that Latch detects the dead peer and cleans up socket descriptors in a timely manner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions