Conversation
Add heartbeat=30.0 to the STT ws_connect and raise a retryable APIConnectionError from recv_task on WSMsgType.ERROR, with ws.exception() attached, so _main_task reconnects and the reason is logged. Same fix as livekit#7206 for Deepgram v1 and livekit#7357 for Soniox.
This was referenced Sep 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a half-open connection (no FIN, no RST) the Telnyx STT
SpeechStreamsits on a dead socket forever: the session stays open, no transcripts arrive, and nothing is ever logged.Two things cause it, same class as Deepgram v1 before #7206 and Soniox in #7357.
_connect_wsopens the socket withoutheartbeat, sorecv_taskparks onws.receive()and the retry in_main_task, which only runs when something raises, never gets a turn. This plugin has no keepalive task, so when audio stops nothing else touches the socket either. And aWSMsgType.ERROR(how a heartbeat timeout arrives) was logged and stepped over; the loop only ended because aCLOSEDfollowed, raised as a generic "closed unexpectedly" with the reason onws.exception()dropped.This adds
heartbeat=30.0(parity with Deepgram and Muse) and raises a retryableAPIConnectionErrorfrom the ERROR frame withws.exception()as the cause, so_main_taskreconnects deterministically and the log says why.Verified against a local fake Telnyx server that goes dead 10s into each connection while keeping the TCP socket open, with a real
SpeechStreampushing silence for 120s. Onmainthe last transcript is at 9.2s, nothing is logged for the remaining 110s, and one socket is opened. With this change the plugin logsTelnyx STT connection lost (caused by ServerTimeoutError: No PONG received after 15.0 seconds)at 55.8s, reconnects, and transcripts resume at 57s; three sockets over the run. Two regression tests added in a newtests/test_plugin_telnyx_stt.py; both fail onmain.This deliberately leaves the send path alone. #6474 covers send-side drops across several plugins including this one, and the two changes are independent.
30s heartbeat means ~46s to detect, which is long for a live call. Kept it for parity; happy to lower it.
Closes #7358.