Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using WebSocket on Windows 7

I just installed Visual Studio 2012 RC and tried to run a service with netHttpBinding enabling WebSocket and get the following error:

This platform does not support server side WebSockets.

The sample I am running is from http://blogs.microsoft.co.il/blogs/idof/archive/2012/03/01/what-s-new-in-wcf-4-5-websocket-support-part-1-of-2.aspx

Can WebSockets work on Windows 7 with Visual Studio 2012 RC?

like image 246
np-hard Avatar asked Jun 14 '12 18:06

np-hard


People also ask

Does Windows 7 support WebSockets?

WebSockets namespace are supported on Windows 7, Windows Vista SP2, and Windows Server 2008.

How do I enable WebSockets in Windows?

- In Control Panel, click Programs and Features, and then click Turn Windows features on or off. Expand Internet Information Services, expand World Wide Web Services, expand Application Development Features, and then select WebSocket Protocol. Click OK. Click Close.


2 Answers

No, websockets is only natively supported by Windows in Windows 8, regardless of which visual studio version you are using.

http://www.paulbatum.com/2011/09/getting-started-with-websockets-in.html

This is due to some low level issues in Windows 7 with http.sys.

There's an offchance it may be backported, but seems unlikely: http://weblogs.asp.net/owscott/archive/2012/03/01/what-s-new-in-iis-8.aspx

To use websockets on Windows 7, you'll have to write your own service.

Try using this for clientside: http://websocket4net.codeplex.com/

and this for server side: http://superwebsocket.codeplex.com/

like image 97
Nik Avatar answered Oct 05 '22 20:10

Nik


I ran into the same problem and solved it by using Fleck. Trivially simple to implement:

One. NuGet add Fleck reference

Two. Create your webserver socket

// Create Websocket server websocketServer = new Fleck.WebSocketServer("ws://localhost:82"); websocketServer.Start(socket => {     socket.OnOpen = () => Console.WriteLine("Open!");     socket.OnClose = () => Console.WriteLine("Close!");     socket.OnMessage = message => socket.Send(message); }); 

I now have a a ASP.NET Self Host web API on one port and the websockets connection running along side it.

like image 27
tonycoupland Avatar answered Oct 05 '22 20:10

tonycoupland