agents icon indicating copy to clipboard operation
agents copied to clipboard

telnyx STT: a silently dropped WebSocket is never detected

Open sidxh opened this issue 2 months ago • 0 comments

Bug Description

On a half-open connection (no FIN, no RST) the Telnyx STT SpeechStream sits on a dead socket forever: the session stays open, no transcripts arrive, and nothing is ever logged. Same class of bug as #7206 (Deepgram v1) and #7356 (Soniox), still present in livekit-plugins-telnyx.

_connect_ws opens the socket without heartbeat, so recv_task parks on ws.receive() and the retry in _main_task, which only runs when something raises, never gets a turn. There is no keepalive task in this plugin, so nothing else touches the socket when audio stops. And when a heartbeat is on, the resulting WSMsgType.ERROR is logged and the loop keeps receiving; it only ends because a CLOSED follows, raised as a generic "closed unexpectedly" with the actual reason from ws.exception() dropped.

Expected Behavior

The dropped connection is detected within the heartbeat window and _main_task reconnects, with the reason attached to the error it logs.

Reproduction Steps

Run a real telnyx.STT(base_url="ws://127.0.0.1:8766") stream against a local aiohttp WebSocket server with autoping=False that answers audio frames with {"transcript", "is_final"} messages for 10s and then stops reading, stops writing, and stops answering pings while keeping the TCP socket open. Push 20ms silence frames for 120s.

On main: last transcript at 9.2s, no warning or error logged for the remaining 110s, one socket for the whole run.

Versions

livekit-agents 1.8.2, livekit-plugins-telnyx at main (e5024c76d), aiohttp 3.14.3, Python 3.13, macOS.

sidxh avatar Sep 19 '26 21:09 sidxh