SignalR持久连接的超时是多少?

Dur*_*sad 4 asp.net-mvc signalr

我使用SignalR和Asp.net MVC创建了聊天应用程序.如果用户有空闲时间,他没有收到来自服务器的任何消息.

SignalR持久连接是否有超时?

如果是,我如何修改或重新激活我的连接?

Tim*_*mes 9

现在已经在维基上升级了https://github.com/SignalR/SignalR/wiki/Configuring-SignalR

using System;
using SignalR;

namespace WebApplication1
{
    public class Global : System.Web.HttpApplication
    {
        void Application_Start(object sender, EventArgs e)
        {
            // Make connections wait 50s maximum for any response. After
            // 50s are up, trigger a timeout command and make the client reconnect.
            GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(50);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)


dav*_*owl 6

对于任何连接,SignalR的默认超时为110秒.它会自动重新连接,你不应该错过任何消息.听起来你有其他一些问题.如果你想像这样调整0.4的超时(假设是asp.net):

// Make idle connections reconnect every 60 seconds
AspNetHost.DependencyResolver.Resolve<IConfigurtionManager>().ReconnectTimeout = TimeSpan.FromSeconds(60);
Run Code Online (Sandbox Code Playgroud)

确保使用SignalR.Infrastructure添加Resolve扩展方法(我们将在下一版本中修复此问题).