Repository navigation
wake: keep the spotter stream alive on a busy host - #26
Merged
Merged
Conversation
ryysel
force-pushed
the
pr/wake-keepalive
branch
from
November 1, 2026 20:36
8d49fe0 to
398ca40
Compare
yawaflua
approved these changes
Nov 3, 2026
Merged
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.
What
feed_all), so Vosk decoding and the Whisper frame math never run on the asyncio event loop.serve()gets an explicitping_interval=20, ping_timeout=60(was the library default of 20/20).Writetimeout goes from one second to five: the websocket library closes the whole connection when a write deadline expires, so a single slow write used to kill the spotter stream.Why
On a busy host the server logs looked like this every few minutes:
While the loop is inside
KaldiRecognizer.AcceptWaveform, it cannot process the pong for the spotter's keepalive ping. The websockets server then closes the stream, the agent reconnects, and any wake word spoken during that window is lost. The box reached load ~35 on 8 cores during a RAID check and a concurrent build, so this was reproducible.Moving the decode to a worker keeps frame order (one worker per connection) and leaves the event loop free to answer pings.
The second half is the other side of the same stall: under load the spotter may stop reading for a moment, the client's one-second write deadline expires, and the library tears the connection down. Five seconds rides out a spike; a truly dead peer still fails fast enough for
runWaketo reconnect.Tests
python3 -m py_compile deploy/wake/wake_server.py,go build ./internal/wake/.ws://…:2700returns{"keyword": "маруся", "engine": "vosk", "score": 1.0}; the same stream with «Алиса» and keywords[маруся]returns no detection.No protocol change.