Websocket issue with IIS 8 Express on Windows 7

2019-02-16 17:29发布

问题:

I tried creating handler for web socket but context.IsWebSocketRequest is returning always false and failed to working with IIS 8 Express on windows 7.

How can I enable module for websocket or any step I missing? I have VS 2012 application with IIS Express dynamic url.

Please help for the same.

回答1:

The WebSocket protocol needs to be enabled in IIS 8 (see http://www.codeguru.com/csharp/csharp/programming-html5-web-sockets-in-asp.net-4.5.htm). Additionally, I'm not sure web sockets is supported on Windows 7. I've only seen that Windows 8 or Windows Server 2012 are required.



回答2:

The short answer is, you can write applications against WebSockets in Windows 7 using IIS 8 Express, but you can't actually test them. It requires Windows 8 or Windows Server 2012.

From the IIS 8.0 Express ReadMe:

WebSocket Support

IIS 8.0 Express supports writing WebSocket applications. For more information, see the WebSocket protocol specification or the System.Net.WebSockets Namespace topic on Microsoft's MSDN website.

Windows Server 2012 and Windows 8 features that do not work on Down-Level Operating Systems

There are a few features which require architecture that is specific to Windows Server 2012 and Windows 8 Client that will not work down-level when you install IIS 8.0 Express on earlier operating systems:

Server Name Indication (SNI)
Central Certificate Store
WebSocket Functionality

Then, from the System.Net.WebSockets MSDN entry (emphasis mine):

Some of the classes in the System.Net.WebSockets namespace are supported on Windows 7, Windows Vista SP2, and Windows Server 2008. However, the only public implementations of client and server WebSockets are supported on Windows 8 and Windows Server 2012. The classes and class elements in the System.Net.WebSockets namespace that are supported on Windows 7, Windows Vista SP2, and Windows Server 2008 are abstract classes. This allows an application developer to inherit and extend these abstract classes with an actual implementation of client WebSockets.