Signalr always falls to long polling in the production server

3.9k Views Asked by At

When i host the application in the server it checks for the server side events and falls back to long polling always. The server hosting environment is Windows Server 2012 R1 and IIS 7.5

Is there anyway if we can solve this issue?

https://cloud.githubusercontent.com/assets/9750273/5050991/2f4cb262-6c59-11e4-9e35-db06b432d470.png

IE10, Chrome 38.0.2125.111 and Firefox.. In all the 3 browsers i am getting long polling, server sent events is cancelled. As i understand few of them had told if the server is behind a proxy and firewall then server sent events may not work. Since the site is in production server i do not have any control on it.

What are the possibilities to cause this issue? How to debug the same?

3

There are 3 best solutions below

1
On

Microsoft has a blog post about getting SignalR working in Server 2008 R2 with IIS 7.5. The directions are likely similar.

  1. Update the SignalR application's web.config file to enable "run all managed modules for all requests" (for short, this is the RAMMFAR setting).

    1. Update the web page that uses SignalR to communicate with the server:

      • Add a reference to the json2.js library.
      • Add a tag that forces the content to display in a recent browser mode.
    2. Set up a Windows Server 2008r2 with IIS 7.5 as follows:

      • Install the .NET Framework version that your SignalR application requires.
      • Create a site and associate it with the appropriate application pool.

Here's how you do the RAMMFAR setting.

<system.webServer>
   <modules runAllManagedModulesForAllRequests="true">
   </modules>
</system.webServer>

I don't think it's necessary to add the json2.js library reference. But here's the meta tag that you should place in your web pages in the head:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

For the application pool in IIS, use integrated mode, not classic. And of course, use .NET 4.0.

5
On

You should enable WebSocket if you want support for it in IIS

Here's a screenshot of the Role/Feature you need to enable to make it work:

WebSocket protocol support

I hope that helps you! :)

2
On

SignalR is based on Web RTC. Web RTC create a persistent TCP connection between browser and a server. HTTP connections are not persistent. Every time your browser make a call to a server it could create a new TCP connection for this request and get a response. Persistant connection are problematical for proxy servers. it is also difficult to using signalR with load balancing. You have multiple web servers and a loadbalancer (could be a proxy) choose transfer your request to one of the web servers in your farm, so the client could only get a connection to your loadbalancer.

BUT: first of all check if the Web RTC is enabled on your production web server!