Background and Motivation
Related to #18840
When debugging a server-side blazor app customers 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 disruptive, requiring a refresh of the browser to recover after continuing the debug session.
The workaround for this is to set serverTimeoutInMilliseconds for HubConnection in Blazor.start.
Blazor.start({
configureSignalR: function (builder) {
let c = builder.build();
c.serverTimeoutInMilliseconds = 60000;
c.keepAliveIntervalInMilliseconds = 30000;
builder.build = () => {
return c;
};
};
})
Instead of overriding build method of HubConnectionBuilder with set serverTimeoutInMilliseconds it would be nice to set this things directly in the builder:
Blazor.start({
configureSignalR: function (builder) {
builder.serverTimeoutInMilliseconds = 60000;
builder.keepAliveIntervalInMilliseconds = 30000;
};
});
Proposed API
TypeScript Client
Enable configuring the connection timeouts in HubConnectionBuilder like serverTimeoutInMilliseconds and keepAliveIntervalInMilliseconds .
class HubConnectionBuilder {
+ public serverTimeoutInMilliseconds?: number;
+
+ public keepAliveIntervalInMilliseconds?: number;
public reconnectPolicy?: IRetryPolicy;
public configureLogging(logLevel: LogLevel): HubConnectionBuilder;
public withUrl(url: string): HubConnectionBuilder;
public withAutomaticReconnect(): HubConnectionBuilder;
}
C# Client
public class HubConnectionBuilder : IHubConnectionBuilder
{
public IServiceCollection Services { get; }
+ public TimeSpan? ServerTimeout { get; set; }
+ public TimeSpan? KeepAliveInterval { get; set; }
public HubConnectionBuilder();
public HubConnection Build();
}
public static class HubConnectionBuilderExtensions
{
public static IHubConnectionBuilder ConfigureLogging(this IHubConnectionBuilder hubConnectionBuilder, Action<ILoggingBuilder> configureLogging);
public static IHubConnectionBuilder WithAutomaticReconnect(this IHubConnectionBuilder hubConnectionBuilder, TimeSpan[] reconnectDelays);
}
Usage Examples
Customers will use it to configure the connection timeout in server-side blazor app like so:
Blazor.start({
configureSignalR: function (builder) {
builder.serverTimeoutInMilliseconds = 60000;
builder.keepAliveIntervalInMilliseconds = 30000;
};
});
Alternative Designs
As an alternative we can add a delegate to Blazor.start to configure HubConnection
Blazor.start({
configureSignalR: builder => builder.configureLogging("debug"),
configureConnection: function (connection) {
connection.serverTimeoutInMilliseconds = 60000;
connection.keepAliveIntervalInMilliseconds = 30000;
},
});
Risks
I'm don't think there are any
Background and Motivation
Related to #18840
When debugging a server-side blazor app customers 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 disruptive, requiring a refresh of the browser to recover after continuing the debug session.
The workaround for this is to set
serverTimeoutInMillisecondsforHubConnectioninBlazor.start.Instead of overriding build method of
HubConnectionBuilderwith setserverTimeoutInMillisecondsit would be nice to set this things directly in the builder:Proposed API
TypeScript Client
Enable configuring the connection timeouts in
HubConnectionBuilderlikeserverTimeoutInMillisecondsandkeepAliveIntervalInMilliseconds.class HubConnectionBuilder { + public serverTimeoutInMilliseconds?: number; + + public keepAliveIntervalInMilliseconds?: number; public reconnectPolicy?: IRetryPolicy; public configureLogging(logLevel: LogLevel): HubConnectionBuilder; public withUrl(url: string): HubConnectionBuilder; public withAutomaticReconnect(): HubConnectionBuilder; }C# Client
public class HubConnectionBuilder : IHubConnectionBuilder { public IServiceCollection Services { get; } + public TimeSpan? ServerTimeout { get; set; } + public TimeSpan? KeepAliveInterval { get; set; } public HubConnectionBuilder(); public HubConnection Build(); } public static class HubConnectionBuilderExtensions { public static IHubConnectionBuilder ConfigureLogging(this IHubConnectionBuilder hubConnectionBuilder, Action<ILoggingBuilder> configureLogging); public static IHubConnectionBuilder WithAutomaticReconnect(this IHubConnectionBuilder hubConnectionBuilder, TimeSpan[] reconnectDelays); }Usage Examples
Customers will use it to configure the connection timeout in server-side blazor app like so:
Alternative Designs
As an alternative we can add a delegate to
Blazor.startto configureHubConnectionRisks
I'm don't think there are any