ReconnectionConfig
Configuration for automatic WebSocket reconnection with exponential backoff.
Defined in: src/core/types/config.ts:107
Configuration for automatic WebSocket reconnection with exponential backoff.
Remarks
WebSocket-based providers (e.g., DeepgramSTT, DeepgramTTS) can lose their connection due to network issues. When reconnection is enabled, the SDK automatically attempts to re-establish the connection using exponential backoff.
The delay between attempts is calculated as: min(initialDelay * backoffMultiplier ^ attempt, maxDelay)
Example
const reconnection: ReconnectionConfig = {
enabled: true,
maxAttempts: 5,
initialDelay: 1000,
maxDelay: 30000,
backoffMultiplier: 2,
};
See
- DEFAULT_RECONNECTION_CONFIG for default values
- CompositeVoiceConfig for where this is used
Properties
| Property | Type | Default value | Description | Defined in |
|---|---|---|---|---|
backoffMultiplier? | number | 2 | Multiplier applied to the delay after each failed attempt. Remarks A value of 2 doubles the delay each time: 1s, 2s, 4s, 8s, … | src/core/types/config.ts:150 |
enabled | boolean | true (via DEFAULT_RECONNECTION_CONFIG) | Whether automatic reconnection is enabled. | src/core/types/config.ts:113 |
initialDelay? | number | 1000 | Initial delay before the first reconnection attempt, in milliseconds. | src/core/types/config.ts:130 |
maxAttempts? | number | 5 | Maximum number of reconnection attempts before giving up. Remarks After this many failed attempts, the SDK emits an error event and stops retrying. | src/core/types/config.ts:123 |
maxDelay? | number | 30000 | Maximum delay between reconnection attempts, in milliseconds. Remarks Caps the exponential backoff to prevent excessively long waits. | src/core/types/config.ts:140 |