【发布时间】:2022-12-14 18:39:18
【问题描述】:
我已经使用以下配置设置了一个 signalr API 端点(仅限 WS):
.AddHubOptions<MyHub>(options =>
{
options.ClientTimeoutInterval = TimeSpan.FromSeconds(120);
options.KeepAliveInterval = TimeSpan.FromSeconds(60);
})
现在,.net 客户端应用程序每约 15 秒对端点执行一次 ping 操作,并在几次尝试后关闭。 如何配置 .net 客户端每 60 秒 ping 服务器一次? 我检查了以下代码,但没有帮助:
.WithUrl("signalrendpointaddress", options =>
{
options.CloseTimeout = TimeSpan.FromSeconds(120);
options.WebSocketConfiguration = (configuration) => { configuration.KeepAliveInterval = TimeSpan.FromSeconds(60); };
})
【问题讨论】:
-
可以尝试参考官方doc。
KeepAliveInterval和ServerTimeout都需要改。建议ServerTimeout值是KeepAliveInterval值的两倍。
标签: c# asp.net-core signalr signalr-hub