generated from deepgram/oss-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
Proposed changes
Add built-in support for:
-
Connection health monitoring
- Application-level heartbeat mechanism to detect silent disconnects (e.g., network path failures, NAT timeouts, server crashes) where no WebSocket close frame is received and the connection appears open but is actually dead
-
Automatic reconnection - Optional auto-reconnect with configurable:
- Max retry attempts
- Backoff strategy (exponential, linear)
- Retry delays
-
KeepAlive auto-send
- Optional automatic KeepAlive message sending at configurable intervals (default 8s for Agent, 10s for STT)
Context
Currently, the SDK provides low-level primitives (disconnect(), reconnect(), keepAlive()) but requires developers to implement their own:
- KeepAlive interval timers
- Silent disconnect detection (no ping/pong or heartbeat mechanism)
- Reconnection logic with backoff
- Timestamp offset tracking across reconnections
This is error-prone and leads to duplicated boilerplate across applications. Long-running streaming sessions are particularly vulnerable to silent network failures that go undetected for 30-90+ seconds.
Possible Implementation
- Reference implementation: Socket.IO ping/pong mechanism - Socket.IO sends periodic ping packets and expects pong responses within a timeout. If no pong is received, the connection is considered dead and closed. This is a well-established pattern for detecting silent disconnects.
- The official docs recommend these patterns at Recovering From Connection Errors
Metadata
Metadata
Assignees
Labels
No labels