SignalR–Configuring timeout for connections
Based on the SignalR wiki, in order to make SignalR work with Azure or load balancers, you will need to tune it such that the polling timeout is lesser than the default polling time of 110 seconds.
To do this, the wiki at https://github.com/SignalR/SignalR/wiki/Configuring-SignalR tells you to do the following
ASP.NET Example (Global.asax)
var config = AspNetHost.DependencyResolver.Resolve<IConfigurationManager>(); config.ReconnectionTimeout = TimeSpan.FromSeconds(25);
However if you were to just copy and paste that, you will find that visual studio reports the following 2 errors and wurlies on your code
The name ‘AspNetHost’ does not exist in the current context
and
The type or namespace name ‘IConfigurationManager’ could not be found (are you missing a using directive or an assembly reference?)
Actually what happens is that the wiki actually forgot to mention that you will actually need to import a few namespaces to global.asax.
They are
- SignalR.Configuration – Fixes the IConfigurationManager
- SignalR.Hosting.AspNet – Fixes AspNetHost
- SignalR.Infrastructure – This is where the Resolve extension reside
- So after adding all these, your global.asax will look like
<%@ Application Language="C#" %>
<%@ Import Namespace="SignalR.Configuration" %><%@ Import Namespace="SignalR.Hosting.AspNet" %>
<%@ Import Namespace="SignalR.Infrastructure" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startupvar config = AspNetHost.DependencyResolver.Resolve<IConfigurationManager>();
config.ReconnectionTimeout = TimeSpan.FromSeconds(25);
}
</script>
Enjoy!




