Configuring SignalR

davidfowl edited this page Feb 24, 2013 · 17 revisions

Configuring SignalR

Each host has access to an IConfigurationManager which allows you to tweak some default SignalR settings. Some things that can be tweaked are:

  1. ConnectionTimeout - Represents the amount of time to leave a connection open before timing out. Default is 110 seconds.
  2. DisconnectTimeout - Represents the amount of time to wait after a connection goes away before raising the disconnect event. Default is 30 seconds.
  3. KeepAlive - Representing the amount of time to wait before sending a keep alive packet over an idle connection. Set to null to disable keep alive. This is set to 30 seconds by default. When this is on, the ConnectionTimeout will have no effect.

ASP.NET Example (Global.asax)

using System;
using Microsoft.AspNet.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);
        }
    }
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.