Reputation: 51
I've set up a signalr API endpoint (WS only) with the following configuration:
.AddHubOptions<MyHub>(options =>
{
options.ClientTimeoutInterval = TimeSpan.FromSeconds(120);
options.KeepAliveInterval = TimeSpan.FromSeconds(60);
})
Now, the .net client application pings the endpoint every ~15 seconds and gets closed after few tries. How to configure the .net client to ping the server every 60 seconds? I've checked the following code, but it didn't help:
.WithUrl("signalrendpointaddress", options =>
{
options.CloseTimeout = TimeSpan.FromSeconds(120);
options.WebSocketConfiguration = (configuration) => { configuration.KeepAliveInterval = TimeSpan.FromSeconds(60); };
})
Upvotes: 1
Views: 1300
Reputation: 18169
If you want to change KeepAliveInterval
to 60 seconds,you need to change serverTimeoutInMilliseconds
.
var connection = new signalR.HubConnectionBuilder().withUrl("/chatHub").build();
connection.serverTimeoutInMilliseconds = 2 * 60 * 1000;
serverTimeoutInMilliseconds:
The server timeout in milliseconds. If this timeout elapses without receiving any messages from the server, the connection will be terminated with an error. The default timeout value is 30,000 milliseconds (30 seconds).
For more details,you can refer to the official doc.
Upvotes: 1