Add multi-server support to the daemon CLI#205
Draft
maximmaxim345 wants to merge 4 commits intomainfrom
Draft
Conversation
When the server reconnects to the daemon (same client_id, new websocket), the old code sent a goodbye message before handshaking the new connection. This caused the server to remove the client from its group and stop playback, requiring manual intervention to resume. Reorder _handle_server_connection to handshake the new connection first, then tear down the old one. The server's attach_connection() atomically replaces the websocket for the same client_id, so the client never leaves the group and playback continues uninterrupted. Also drop the RuntimeError in _on_audio_chunk when the audio worker isn't running — just log at debug level and drop the chunk, since this is a benign race during connection transitions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
On server-initiated reconnection, the old client's audio chunk listeners were never unregistered. This left a brief window where chunks from the old WebSocket could arrive and hit the audio handler after the worker was stopped. Call detach_client() before _handle_disconnect() to cleanly unsubscribe the old listeners first. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Instead of logging every dropped chunk at debug level (which can be extremely noisy during reconnection races), log only when entering the dropping state and reset when chunks flow again. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Per the protocol spec, the daemon now decides which server to keep when multiple servers connect, based on connection reason and a persisted last-played server ID.
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.
Note
In draft, since this depends on Sendspin/aiosendspin#201 being released (held back due to some edge cases with the new player delay additions).
Currently includes changes from #202
Add multi-server support when running the
sendspin daemon.Servers are now allowed to discover the daemon, while only the last playing server is allowed to stay connected.
Fixes the reconnect loop mentioned in Sendspin/aiosendspin#201.