也许你不应该增加超时时间。请看这question,因为它解释了你可以观察到的行为。适当的行动是检查客户端提到的问题并相应处理,而不会增加超时时间。
但正如你所问,这里是你如何做到这一点。将其添加到启动类中。
// Make long polling connections wait a maximum of 110 seconds for a
// response. When that time expires, trigger a timeout command and
// make the client reconnect.
GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(110);
// Wait a maximum of 30 seconds after a transport connection is lost
// before raising the Disconnected event to terminate the SignalR connection.
GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(30);
// For transports other than long polling, send a keepalive packet every
// 10 seconds.
// This value must be no more than 1/3 of the DisconnectTimeout value.
GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(10);
您需要增加DisconnectTimeout
。有一点要记住:设置顺序KeepAlive
和DisconnectTimeout
是重要的。如果您在设置KeepAlive
后设置DisconnectTimeout
,则会覆盖KeepAlive
的值。
你不会增加这个超时。我会搜索你有这个超时的原因。 – Tester