C
C#2mo ago
Natty

Blazor HubConnectionBuilder Timeouts

Does this work for anyone?
hubConnection = new HubConnectionBuilder()
.WithUrl(Navigation.ToAbsoluteUri($"/chatroomhub"))
.WithServerTimeout(TimeSpan.FromSeconds(30))
.WithKeepAliveInterval(TimeSpan.FromSeconds(15))
.Build();
hubConnection = new HubConnectionBuilder()
.WithUrl(Navigation.ToAbsoluteUri($"/chatroomhub"))
.WithServerTimeout(TimeSpan.FromSeconds(30))
.WithKeepAliveInterval(TimeSpan.FromSeconds(15))
.Build();
I can navigate away from the page for minutes and nothing happens. Connection is never closed...
1 Reply
Natty
Natty2mo ago
All I want is for the server to time out, after X seconds of inactivity. Only way I could find to resolve this was by setting in Program.cs
builder.Services.AddSignalR().AddHubOptions<ChatRoomHub>(options =>
{
options.KeepAliveInterval = TimeSpan.FromSeconds(60);
});
builder.Services.AddSignalR().AddHubOptions<ChatRoomHub>(options =>
{
options.KeepAliveInterval = TimeSpan.FromSeconds(60);
});
And in the Hub
hubConnection = new HubConnectionBuilder()
.WithUrl(Navigation.ToAbsoluteUri($"/chatroomhub"))
.WithServerTimeout(TimeSpan.FromSeconds(30))
.Build();
hubConnection = new HubConnectionBuilder()
.WithUrl(Navigation.ToAbsoluteUri($"/chatroomhub"))
.WithServerTimeout(TimeSpan.FromSeconds(30))
.Build();
So, intentionally setting the KeepAliveInterval to be longer than the ServerTimeout. If i don't specify the KeepAliveInterval at all, then the server NEVER times out. This does not seem right to me...
Want results from more Discord servers?
Add your server
More Posts