带AutomaticReconnect()的“ Azure SignalR”,“错误:连接因错误而断开连接”………在Angular8和Asp.Net Core 3.1上

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

我正在Asp.Net Core 3.1和Angular8上使用Azure SignalR。我还在客户端使用了withAutomaticReconnect()选项。它与天蓝色信号器成功连接。但是一段时间后,它显示此错误消息并再次连接到WebSocket。

enter image description here

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

错误:连接已断开,错误为'错误:服务器超时,但未收到来自服务器的消息。'

默认serverTimeoutInMilliseconds值为30,000毫秒(30秒),如果在没有收到来自服务器的任何消息的情况下超时,则连接将终止,并出现上述错误。

请检查您是否配置/更改了SignalR集线器服务器的serverTimeoutInMilliseconds

[更改KeepAliveIntervaloption时,我们应该在客户端更改KeepAliveInterval设置。推荐的KeepAliveInterval值是serverTimeoutInMilliseconds值的两倍。

例如:

在中心服务器上,将KeepAliveInterval更改为1分钟

serverTimeoutInMilliseconds

在客户端,将serverTimeoutInMilliseconds更改为2分钟

KeepAliveInterval

测试结果

services.AddSignalR(hubOptions => { hubOptions.KeepAliveInterval = TimeSpan.FromMinutes(1); }).AddAzureSignalR();

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