-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Customizable serverTimeoutInMilliseconds in Server-Side Blazor #18840
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
Comments
Yeah, debugging is a problematic thing for timeouts. We actually disable server-side timeouts when a debugger is attached but can’t control client-side timeouts in the same way.
Right now it can only be set on the HubConnection in the client. Either Blazor will have to expose the HubConnection or SignalR will have to add support for setting the property in HubConnectionBuilder (or both). Seems like a reasonable ask, but it’s new API and not patchable. If someone wants to file a bug for the SignalR fix that would be great (on my phone at the moment). In the short-term (since adding new APIs is a 5.0 change) is it possible to dig the HubConnection object out of Blazor somehow? Remember that “private” in TypeScript doesn’t mean anything :). It might also be possible to hack in a hook somehow. If it’s ONLY used in Development, it would be fairly reasonable to do something sneaky here ;).
We don’t support setting client options via server configuration by design. It was something that ASP.NET SignalR (for OWIN/System.Web apps) supported but it causes problems. This is the client’s timeout so it should be owned/set by the client. |
Thanks, @anurse. I'd love to try something sneaky, but I haven't been able to come up with any way to get a hold of that HubConnection object. I don't see it getting stashed away anywhere. It seems to be referenced only as a method-scoped variable or parameter. And it doesn't seem to be passed to any functions I can hook into. As far as I can tell this internal implementation detail was successfully kept internal. |
We've moved this issue to the Backlog milestone. This means that it is not going to happen for the coming release. We will reassess the backlog following the current release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources. |
Thanks for contacting us. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
hi, is there any update on this feature request? |
Here's how I worked around this issue: Blazor.start({
configureSignalR: function (builder) {
let c = builder.build();
c.serverTimeoutInMilliseconds = 60000;
c.keepAliveIntervalInMilliseconds = 30000;
builder.build = () => {
return c;
};
};
}); |
Just FYI for everybody, the above code is placed inside |
Thanks for contacting us. We're moving this issue to the |
This is resolved now. I understand the feedback.
protected override async Task OnInitializedAsync()
{
hubConnection = new HubConnectionBuilder()
.WithUrl(Navigation.ToAbsoluteUri("/chathub"))
.Build();
hubConnection.ServerTimeout = TimeSpan.FromSeconds(61);
hubConnection.HandshakeTimeout = TimeSpan.FromSeconds(31);
hubConnection.KeepAliveInterval = TimeSpan.FromSeconds(17);
Logger.LogInformation($"\n\n\nhubConnection.ServerTimeout: {hubConnection.ServerTimeout}" +
$"\nhubConnection.HandshakeTimeout: {hubConnection.HandshakeTimeout}" +
$"\nhubConnection.KeepAliveInterval: {hubConnection.KeepAliveInterval}\n\n");
hubConnection.On<string, string>( ... );
await hubConnection.StartAsync();
}
|
@guardrex I am not sure what you are trying to get at. The snippet you described is for opening a hub within the app, not for configuring the Blazor Server hub. For that, the only thing that works is: Blazor.start({
configureSignalR: function (builder) {
let c = builder.build();
c.serverTimeoutInMilliseconds = 60000;
c.keepAliveIntervalInMilliseconds = 30000;
builder.build = () => {
return c;
};
};
}); |
This is resolved now. I understand the feedback.
|
This is resolved now. I understand the feedback.
|
@surayya-MS can you help bring clarity to the docs? |
This is resolved now. I understand the feedback.
builder.Services.AddServerSideBlazor()
.AddHubOptions(options =>
{
options.ClientTimeoutInterval = TimeSpan.FromSeconds(60);
options.HandshakeTimeout = TimeSpan.FromSeconds(30);
options.KeepAliveInterval = TimeSpan.FromSeconds(15);
});
builder.Services.AddSignalR(options =>
{
options.ClientTimeoutInterval = TimeSpan.FromSeconds(60);
options.HandshakeTimeout = TimeSpan.FromSeconds(30);
options.KeepAliveInterval = TimeSpan.FromSeconds(15);
});
hubConnection.ServerTimeout = TimeSpan.FromSeconds(60);
hubConnection.HandshakeTimeout = TimeSpan.FromSeconds(30);
hubConnection.KeepAliveInterval = TimeSpan.FromSeconds(15);
|
@guardrex that controls the timeouts on the server waiting on clients, the other controls the timeouts from the client waiting on the server. |
It is not possible to set serverTimeoutInMilliseconds in The workaround works because it overrides the build method of the builder to return the hub connection with set serverTimeoutInMilliseconds. Blazor.start({
configureSignalR: function (builder) {
let c = builder.build();
c.serverTimeoutInMilliseconds = 60000;
c.keepAliveIntervalInMilliseconds = 30000;
builder.build = () => {
return c;
};
};
}); |
Remarks removed and summarized (thank goodness! 🙈) on the docs PR at dotnet/AspNetCore.Docs#27374. |
Tagging this as SignalR as we would like to be able to set these options in the builder directly rather than having to expose an extra knob. |
When debugging a server-side blazor app we often see this error pop up in the client (browser) while stepping through code:
Error: Connection disconnected with error 'Error: Server timeout elapsed without receiving a message from the server.'.
This can be pretty disruptive, requiring a refresh of the browser to recover after continuing the debug session.
Presumably, this happens because the server isn't sending keepalives on the SignalR connection while I'm stepping through code in the debugger. When running in a 'development' environment, I'd like to be able to customize the serverTimeoutInMilliseconds on the HubConnection to prevent this. I see examples of how to customize the SignalR settings for a server-side Blazor app using code like this:
However, I'm unable to change the serverTimeoutInMilliseconds setting. This setting is available on the HubConnection object, but I don't have access to that object. I only have access to HubConnectionBuilder. And HubConnectionBuilder doesn't have a serverTimeoutInMilliseconds property.
It seems like adding support for configuring the serverTimeoutInMilliseconds via HubConnectionBuilder would be the simplest solution.
Even nicer would be some way to configure this setting in my Startup.cs, probably with a new property available somewhere under the AddServerSideBlazor call, similar to how I can customize the server-side hub settings via AddServerSideBlazor().AddHubOptions(options => ... ).
The text was updated successfully, but these errors were encountered: