Skip to content

fix(websocket): Stop aborting healthy connections and detect dead ones with ping/pong - #64

Merged
x64-dev merged 8 commits into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/websocket-fixes
Sep 25, 2026
Merged

x64-dev merged 8 commits into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/websocket-fixes

Conversation

@tintinhamans

Copy link
Copy Markdown
Contributor

Cancelling a pending ReceiveAsync or SendAsync aborts 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. JSON PING still gets a JSON PONG for 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.

@x64-dev
x64-dev merged commit 6081fd1 into GeneralsOnlineDevelopmentTeam:main Sep 25, 2026
16 checks passed
@tintinhamans
tintinhamans deleted the arctic/websocket-fixes branch September 25, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants