24

On my IIS 7.5, my SignalR application always used long polling. As per my search, IIS 7.5 does not support WebSockets yet.

I hope, I missed some tools or configurations to enable WebSockets in IIS 7.5. Or I didn't?

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
ZeroHackeR
  • 573
  • 1
  • 5
  • 7
  • I dont use IIS, but you can write your own server (program) that will do this stuff for you. With websockets you can connect from browser to any server and port. – Zaffy Jan 02 '13 at 20:19
  • @Zaffy: Thanks. But, I will lose auto-fallback function of SignalR if WebSockets is not available. – ZeroHackeR Jan 03 '13 at 21:01
  • this answer http://stackoverflow.com/questions/17957949/does-self-hosted-signalr-require-windows-server-2012-in-order-to-use-websockets explains why you can't in more detail to the other answers – wal Sep 25 '15 at 00:52
  • For those running into this in 2019, IIS 7.5 or earlier won't let you use web sockets, but .net core / kestrel *will*. Running .net core inside IIS does not work, but running kestrel on its own *does*. – Timothy Groote Jul 03 '19 at 13:37
  • Here in 2021, my solution was this: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/websockets?view=aspnetcore-5.0#iisiis-express-support I needed to enable Web Sockets on my Windows Server 2019 – Kevin Welsh Jul 07 '21 at 15:40

3 Answers3

44

You cannot use WebSocket on IIS 7.5 (in other words on Windows Server 2008 R2 or Windows 7) because it requires HTTP.sys level changes AFAIK. So, you need IIS 8.0 and Windows Server 2012 or Windows 8 combination to leverage WebSocket. Also, IIS Express 8.0 supports WebSockect, too but you cannot still leverage that if you are on an OS which is lower than Windows 8 or Windows Server 2012.

tugberk
  • 57,477
  • 67
  • 243
  • 335
  • Is there any third party tools? I'm doing development on Win 8, but my server is on Win Server 2008 R2. I will check with the hosting provider. – ZeroHackeR Jan 03 '13 at 21:03
  • @ZeroHackeR I have no idea but I believe StackExchange uses WebSocket technology and they are on Windows Server 2008 R2. I have no idea how they do it. Also, it's not just about you and your clients browsers. Any proxy in the middle needs to support WebSocket, too. BTW, it's strange that your SignalR app always uses long polling. I would expect it to use at least forever-frame in IE or SSE in other browsers. – tugberk Jan 03 '13 at 23:36
  • 1
    @ZeroHackeR one alternative could be to use XSocketS.NET (http://xsockets.net/) - it implements web sockets completely outside of IIS. – Icarus Jan 12 '15 at 20:43
  • Wierd, I was using websocket for 3 days, working good, now I developed many changes and I cant use at IIS 7.5 like you said. – Lucas Rodrigues Sena May 28 '15 at 17:32
4

IIS 8 Express Supports websockets New Features

Windows 7 is considered a Down-Level Operating system and doesn't support Web Sockets. Known Issues and Limitations

Time to upgrade to Windows 8 if you want to support for web-sockets!

JJS
  • 6,431
  • 1
  • 54
  • 70
-19

Here's a summary of the required setup steps to host on Windows 2008r2 with IIS 7.5:

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.

Update the Signalr Application's Web.config File

In your SignalR application's web.config file, add the RAMMFAR setting to enable running all managed modules for all requests. This setting was required to get the SignalR sample application running in on Windows 2008r2 and IIS 7.5 in all browsers.

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

Update the Web Page that Uses SignalR

In the application web page that uses SignalR to communicate with the server, add the following code.

Add a reference to the json2.js JSON parser library. This script provides a JSON parser for previous browser versions that don't have it. You can add the script in one of two ways: Add the NuGet package json2.js to your project, and then reference it in your web page:

Or as an alternative, reference json2.js on a CDN:

Add the following tag in the head section of the page. This tag, specifically the IE=edge value, forces Internet Explorer to display content in the most recent version available, rather than earlier modes (such as IE7) which prevent SignalR code from working.

Set up Windows Server 2008r2 and IIS 7.5

As noted, I built the sample SignalR application from the Getting Started with SignalR tutorial on .NET 4. This is a common hosting scenario on Windows 2008r2 and IIS 7.5. The server was a new default default installation of Windows Server 2008r2 and IIS 7.5.

Install the required .NET Framework version. In this case I installed .NET Framework 4. Create a new site in IIS Manager, and associate the site with an application pool. Use integrated mode application pools, classic mode is not supported for SignalR. For this application I used the ASP.NET v4.0 application pool.

After following the above setup steps, I was able to deploy the .NET Framework 4-based version of the Getting Started with SignalR sample to the server, and it worked perfectly in IE (versions 8, 9, and 10), Chrome, and Firefox even though it was using fallback transport methods (forever frames in IE, and server-sent events in the other browsers). The interesting thing for SignalR developers is that apart from the above steps, I didn't have to change a single line of the SignalR code anywhere in the application to make this work.

This is a simple case but shows that SignalR really does support "automatic fallback" to earlier transport mechanisms when websockets support is not available on the server.

Community
  • 1
  • 1
Giuseppe
  • 1,079
  • 13
  • 31