From aace7f9523df976657c7e2363bde23509520b592 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 8 May 2026 22:03:56 +0900 Subject: [PATCH] Enable stateful reconnects (#35658) RFC - Requires https://github.com/ppy/osu-server-spectator/pull/366 to actually function. Resolves https://github.com/ppy/osu/issues/35580 Resolves https://github.com/ppy/osu-server-spectator/issues/193 Resolves https://github.com/ppy/osu/issues/35586 Resolves https://github.com/ppy/osu-server-spectator/issues/362 Resolves https://github.com/ppy/osu/issues/37353 ## Outline This enables stateful reconnect for spectator-server endpoints, allowing ConnectionIds to be preserved for a short period and messages to be replayed on reconnect. In practice, this means short disconnects (<30s) should no longer: - Drop replays - Kick you out of multiplayer rooms - Trigger "user has come online" re-alerts. The following video demonstrates two of the above: https://github.com/user-attachments/assets/b9781f31-a8a1-410e-b0ac-65d3374a33d6 Stateful reconnect appears to kick in as long as the socket doesn't get disconnected, _not_ on subsequent re-connections. We have the timeout period set to SignalR's default of 30sec. I've been using the following to simulate a total link loss: ```sh #!/bin/bash DELAY=${1:-1} echo "Conditioning for $DELAY seconds..." sudo ip link set lo down sudo ss -K dst 127.0.0.2 > /dev/null sleep $DELAY sudo ip link set lo up ``` --- osu.Game/Online/HubClientConnector.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Online/HubClientConnector.cs b/osu.Game/Online/HubClientConnector.cs index c12043c727..03c8cf5c72 100644 --- a/osu.Game/Online/HubClientConnector.cs +++ b/osu.Game/Online/HubClientConnector.cs @@ -64,6 +64,8 @@ namespace osu.Game.Online options.Headers.Add(CLIENT_SESSION_ID_HEADER, API.SessionIdentifier.ToString()); }); + builder.WithStatefulReconnect(); + builder.AddMessagePackProtocol(options => { options.SerializerOptions = SignalRUnionWorkaroundResolver.OPTIONS;