Repository navigation
fix(inference): detect a silently dropped Inference STT socket instead of hanging - #8023
Merged
Merged
Conversation
Contributor
Author
…d of hanging Add heartbeat=30.0 to the Inference STT websocket so a half-open client-to-gateway connection raises instead of parking recv_task forever, and raise a retryable APIConnectionError carrying ws.exception() on WSMsgType.ERROR. Mirrors livekit#7206. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
regalmoix
force-pushed
the
fix/inference-stt-heartbeat
branch
from
October 21, 2026 14:16
8fc9d63 to
4ff9582
Compare
Contributor
Author
|
Closing to retrigger CI — unit-tests hit the unrelated |
davidzhao
approved these changes
Oct 25, 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.
Title: fix(inference): detect a silently dropped Inference STT socket instead of hanging
Same gap as #7900, but in LiveKit Inference STT, which isn't a plugin and isn't covered by the open per-plugin PRs.
inference/stt.pyopens its websocket withoutheartbeat. On a half-open client↔gateway connection (no FIN/RST),recv_taskwaits onws.receive()forever. Nothing raises, so the stream never retries andFallbackAdapternever switches.Scope: this covers the client↔gateway socket only. A provider that goes silent behind a healthy gateway is a separate problem (see the review on #5883, and #7826).
Fix
Same as the merged Deepgram fix (#7206):
heartbeat=30.0onws_connect. This is the fix: aiohttp now closes a socket that stops answering pings.WSMsgType.ERRORraises a retryableAPIConnectionErrorchained fromws.exception(). Before, it was logged as an unexpected type and then surfaced as a bare1006with no cause.Impact
The probe from #7900, adapted to
inference.STT: a local server accepts the session, then never sends and never answers pings. Run withmax_retry=0, streaming silence.The error now carries its cause:
The 46s detection time matches the 30s heartbeat every fixed plugin uses. Shortening it is left to maintainers (see the discussion in #7900).
Testing
test_half_open_socket_raises_retryable_errorruns a real local gateway that never answers pings. It fails onmain, and fails if either change is reverted. 70 runs passed, including under CPU load.uv run pytest --unit --audio_eotpasses, apart fromtest_room.py, which needs alivekit-serverbinary and fails the same way onmain.make checkpasses.Why no regression
input_ended/session.closedguard as the CLOSED branch. Nothing in the repo matches on the old 1006 message.Could a maintainer confirm the gateway/LB answers WS pings? Inference TTS and
/bargeinsockets have the same gap; I'm happy to follow up.