AspNet核心SignalR KeepAlive超时的一些问题

问题描述 投票:1回答:1

在我们的项目中,我已经设置了SignalR如下。

services.AddSignalR()
            .AddHubOptions<NotificationHub>(options =>
            {
                const int keepAliveIntervalInSeconds=60;
                options.EnableDetailedErrors=true;
                options.ClientTimeoutInterval = TimeSpan.FromSeconds(2 * keepAliveIntervalInSeconds);
                options.HandshakeTimeout = TimeSpan.FromSeconds(keepAliveIntervalInSeconds);
                options.KeepAliveInterval = TimeSpan.FromSeconds(keepAliveIntervalInSeconds);
            });

但它并不像它应该做的那样工作。我在客户端得到一个错误,说。

[2020-06-03T09:48:44.367Z] Error: Connection disconnected with error 'Error: Server timeout elapsed without receiving a message from the server.'.

是否有什么地方我做错了?

asp.net-core asp.net-core-signalr
1个回答
1
投票

错误。连接断开,并出现错误'Error.Server timeout elapsed without receiving message from the server.'。服务器超时了,没有收到服务器的消息。

本文档的 "配置服务器选项 "部分,我们可以发现。

默认值为: KeepAliveInterval15秒. 当改变 KeepAliveInterval,我们需要改变 ServerTimeout/serverTimeoutInMilliseconds 设置 在客户端 也。而推荐的 ServerTimeout/serverTimeoutInMilliseconds 的两倍。KeepAliveInterval 值,而默认的超时值为

而默认的超时值为 服务器超时时间在Milliseconds 是30,000毫秒(30秒),如果你只是更新了 KeepAliveInterval 您的SignalR集线器设置为 60秒 不变 serverTimeoutInMilliseconds 值,这将导致上述错误。

© www.soinside.com 2019 - 2024. All rights reserved.