fix(websocket): Stop aborting healthy connections and detect dead ones with ping/pong - #64
Merged
x64-dev merged 8 commits intoSep 25, 2026
Conversation
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.
Cancelling a pending
ReceiveAsyncorSendAsyncaborts the socket, so the 30s receive timeout, the 500ms send timeout and the 20ms tick deadline were silently dropping healthy clients. Receives now only cancel when the request is aborted. Dead connections are detected by protocol ping/pong: 15s interval, 45s timeout. The old app-level timer never fired because the keep-alive pong kept resetting it. JSONPINGstill gets a JSONPONGfor released clients.Sends now go through a per-session queue with one send loop per socket, replacing the tick drain, the send lock and the direct sends. Queued messages survive a reconnect, a client more than 1024 messages behind is dropped, and a send is only cancelled after stalling for 60s. A timed-out close now aborts the socket, since a cancelled close leaves it open behind a stuck send. Also fixed: a failed handshake no longer leaves the session online, the friends status update on connect is no longer lost, disconnects without a close handshake are no longer reported to Sentry (~700k events/month), and the GeoIP fallback coordinates were swapped.