Skip to main content
createVoiceGateway from @agentium/transport connects Socket.IO clients to registered VoiceAgent instances. It reserves sessions before asynchronous setup, cancels late connections after disconnect, and bounds queued audio.

Authenticate connections

When you configure authMiddleware, verify credentials and populate socket.data.auth with { userId, tenantId?, sessionId? }. Client user/session/API-key overrides are ignored in authenticated mode; missing trusted identity rejects setup. Keep provider credentials on the server. The text gateway has a separate required security mode. Do not assume configuring one gateway secures the other.

Client event contract

Sequence acknowledgement and playback confirmation serve different purposes. Only send played-character offsets when backed by audio/text alignment. Send playback completion even if every frame has already been acknowledged.

Bounds and disconnects

Defaults are 256 KiB per frame, 1 MiB pending output, and a 10-second acknowledgement deadline. Malformed audio, overflow, and stalled acknowledgements terminate the session. Configure Socket.IO server and deployment limits separately. During recovery, audio and commits are discarded; text receives a retryable error. No queued inputs are replayed after recovery. A disconnect or local abort does not prove an external tool effect stopped. See native sessions for provider recovery and streaming voice for a coordinator-owned Agent pipeline.