Searched topics:
In above articles if seen an example of setting the timeouts. And also the docs explain there is the client side and the server side, ofc each can suddenly crash/shutdown or the network might be cut etc. so both sides seem to have timeouts to do different things like going "Down"(= trying to reconnect) and finally "Closing". So...
Question #1: how can I set all (at least 4) timeouts (incl. keep alive) for CLIENT and SERVER respectively?
The SO post shows an answer with JS and one inside program.cs, what's the difference? Is it actually server/client? Can the client side be set in C# on startup or does it need to be set in JS? If so, where is the documentation on that?
Question #2: how to know the server-side timeout(s)?
I made a brand new Blazor server project from default template (.NET 6) and added the code from the SO post to see all circuits. When I run it in LAN and the client (other PC) opens the Clicker and then put the PC into full hibernation, I see the OnConnectionDownAsync
event, but even after 2+mins, there was no OnCircuitClosedAsync
(it also actually works. Turning PC on after 2mins will actually let the browser reconnect and raise OnConnectionUpAsync
automatically, without OnCircuitOpenedAsync
). WHY? Is the timeout really long? Where can I read the variable for the default timeout, where to set it? How long does the server keep the info of the circuit, so that a client can reconnect? IT IS NOT 5secs (see link above).
Update: another test confirmed the disconnect timeout seems to be exactly 3mins (180s). Now I need to find out how to set it. Note: It does NOT seem to be options.WebSockets.CloseTimeout
.
It's also not options.ClientTimeoutInterval
.
The docs says something about a
Application_Start
in yourGlobal.asax
I have never read about that. What is that? Is this actually for Blazor or rather some other ASP.NET project types. Is that the only (right) way?? [Edit: Its for older frameworks, not ASP.NET Core 6+]
Question #3: what timeout is the mentioned 5sec there? Its obv. NOT the server timeout until it closes completely.
Question #4: what's the difference between... AddHubOptions
and MapBlazorHub...options
... ?
services.AddServerSideBlazor()
.AddHubOptions(options =>
{
options.ClientTimeoutInterval = TimeSpan.FromMinutes(10);
options.KeepAliveInterval = TimeSpan.FromSeconds(3);
options.HandshakeTimeout = TimeSpan.FromMinutes(10);
});
and
app.UseEndpoints(endpoints =>
// other settings go here
endpoints.MapBlazorHub(options => {
options.WebSockets.CloseTimeout = new TimeSpan(1, 1, 1);
options.LongPolling.PollTimeout = new TimeSpan(1, 0, 0);
})
);
Update: seems like the above link refers to the older version... This might be the newer version. I hope it shines some light...
It answers already this:
CloseTimeout 5 seconds
After the server closes, if the client fails to close within this time interval, the connection is terminated.
What does that mean, "it could take longer", never is it stated that its precisely 180s, why even have the variable if its wrong ??
ClientTimeoutInterval 30 seconds
The server considers the client disconnected if it hasn't received a message (including keep-alive) in this interval. It could take longer than this timeout interval for the client to be marked disconnected due to how this is implemented. The recommended value is double the KeepAliveInterval value.
[Update]:
This seems to be the new documentation. Which answers some of my Questions (partially). I'm still not fully clear on how all the options work together and missing a good working example (which all of them applied and demonstrated).
Especially client timeouts seem kinda inconsistent and confusing, see my other Question about SignalR timing intervals.