问题
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?
回答1:
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:
I hope that helps you! :)
回答2:
Microsoft has a blog post about getting SignalR working in Server 2008 R2 with IIS 7.5. The directions are likely similar.
Update the SignalR application's web.config file to enable "run all managed modules for all requests" (for short, this is the RAMMFAR setting).
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.
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.
回答3:
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!
来源:https://stackoverflow.com/questions/26945710/signalr-always-falls-to-long-polling-in-the-production-server