Reconnect and persistence
The SDK keeps voice calls alive across two classes of disruption:
- Transient WebSocket drops — codes
1006,1011, etc. TheSessionClientreconnects automatically with a configurable backoff. - Page reload mid-call — voice-call state is persisted to
sessionStoragefor ~20 seconds after disconnect, so a refresh during a call can resume cleanly.
Page-reload resume
On mount, ask the client for any persisted call and resume it:
useEffect(() => {
const stored = delphi.restorePersistedCall();
if (stored) {
delphi.reconnectCall(stored).catch(console.error);
}
}, [delphi]);
restorePersistedCall() returns the stored call descriptor or null. reconnectCall(descriptor) opens a fresh voice_conversation session bound to the same endpointId, re-attaches WebRTC, and restores the SIP leg.
The persisted state is only valid for about 20 seconds after disconnect. Beyond that the user should redial. The window protects against accidental reloads, not against intentional dwell time.
Channel WebSocket auto-reconnect
SessionClient reconnects its channel WebSocket on transient disconnects without exposing the gap to callers (state.connected briefly flips to false and back). Configurable via:
const session = await delphi.openSession({
endpointId,
mode: 'audio_playback',
reconnectDelay: 1000, // ms; default uses a short fixed delay
});
Voice sessions reconnect through the same mechanism and the WebRTC peer connection is re-negotiated as needed.
Idle timeout vs reconnect
Reconnect logic is independent of the idle timeout:
- Non-voice sessions still close after
sessionIdleTimeoutMsof true inactivity (no messages in either direction). Reconnects do not extend it; user actions do. - Voice sessions ignore the idle timeout entirely; only
endCall()(or a hard disconnect past the reconnect window) ends them.
What is persisted
The persisted blob is intentionally small:
| Field | Purpose |
|---|---|
endpointId | Which endpoint to resume on. |
sessionId | Server-side session identifier. |
webrtcGatewayUrl | Where the gateway lives. |
telproDomain | TelPro routing hint. |
timestamp | Used to enforce the 20-second window. |
No audio, no transcripts, no API key. Token re-issuance happens server-side via sessionTokenUrl on resume.