-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Enable stateful reconnects #35658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Enable stateful reconnects #35658
Conversation
b90a734 to
680614f
Compare
3f90ca4 to
67277f2
Compare
|
On Discord I was asked about why the connection dies after 30sec. Initially I thought this was just the socket keepalive period, but it appears that is set to 15 seconds. Regardless, I found that there's a second timeout which is that 30s window that we're concerned about, which can be adjusted with the following: diff --git a/osu.Server.Spectator/Startup.cs b/osu.Server.Spectator/Startup.cs
index 3e326cc..028afd2 100644
--- a/osu.Server.Spectator/Startup.cs
+++ b/osu.Server.Spectator/Startup.cs
@@ -29,6 +29,7 @@ namespace osu.Server.Spectator
{
options.AddFilter<LoggingHubFilter>();
options.AddFilter<ConcurrentConnectionLimiter>();
+ options.ClientTimeoutInterval = TimeSpan.FromMinutes(5);
})
.AddMessagePackProtocol(options =>
{
diff --git a/osu.Game/Online/HubClientConnector.cs b/osu.Game/Online/HubClientConnector.cs
index ff9a4261fd..c87ba0812c 100644
--- a/osu.Game/Online/HubClientConnector.cs
+++ b/osu.Game/Online/HubClientConnector.cs
@@ -72,6 +72,7 @@ protected override Task<PersistentEndpointClient> BuildConnectionAsync(Cancellat
options.Headers.Add(CLIENT_SESSION_ID_HEADER, API.SessionIdentifier.ToString());
});
+ builder.WithServerTimeout(TimeSpan.FromMinutes(5));
builder.WithStatefulReconnect();
builder.AddMessagePackProtocol(options =>
I haven't re-tested but I've been able to go up to 1-minute before. I don't know the implications. |
|
Empirical observations from local testing of what this "stateful reconnects" feature is, which I gathered myself because the docs are terrible. Conditions of test:
Conclusions:
Long and short, I'm not sure spending more time on investigation here is useful at this stage, I'll reconsider that tomorrow. My immediate vibes on this are as follows:
|
RFC
Resolves #35580
Resolves ppy/osu-server-spectator#193
Resolves #35586
Resolves ppy/osu-server-spectator#362
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:
The following video demonstrates two of the above:
2025-11-08.19-30-17.mp4
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: