Last post Nov 21, 2011 02:02 AM by pmoskovi
Oct 21, 2011 06:17 PM|Holy Samosa|LINK
I've created a super-simple WebSocket echo service using the Microsoft.WebSockets preview v. 0.1, but unfortunately it never accepts a connection or throws an error. It just hangs out, doing nothing. I'm testing with the websocket.html echo test from
http://websocket.org/echo.html (with a modified WebSocket host address, naturally). I've tested with browsers running locally, so it's not a firewall issue.
Any help would be greatly appreciated. Also, if this isn't the best forum for this post please let me know!
Here's the code:
static void Main(string args)
var host = new WebSocketHost<EchoService>(new Uri("ws://localhost:8080/echo"));
class EchoService : WebSocketService
public override void OnOpen()
public override void OnMessage(string message)
Console.WriteLine("Echoing to client:");
protected override void OnClose()
protected override void OnError()
Console.WriteLine("WebSocket error occured.");
Oct 21, 2011 07:46 PM|Paul Batum|LINK
Your code looks fine to me so its probably an environmental issue or a problem with the client.
I assume you are running the Windows 8 developer preview? Have you used your browser's f12 tools to debug what is happening with the connection? The console in all compatible browsers (IE10/firefox/chrome) should show an error if the connection fails.
Have you tried one of the sample projects? I have a blog post on how to set up and try one of these samples:
Let me know how it goes!
Oct 24, 2011 05:58 PM|Holy Samosa|LINK
I'd previously only tried the code on Windows 7, but I installed the Windows 8 Preview and my web sockets echo server worked like a champ.
The only problem is I need to build a solution that Windows 7 can support. Is there any hope of getting web sockets running with a self-hosted WCF 4.5 web service on Windows 7?
Oct 24, 2011 06:32 PM|Paul Batum|LINK
Glad to hear you managed to get it working! Unfortunately WCF will only support WebSockets on Windows 8 - you will not be able to use this functionality if you install .NET 4.5 on Windows 7. The implementation is reliant on changes made to http.sys (a windows
component) and these changes are only present in Windows 8.
Oct 25, 2011 02:12 PM|Holy Samosa|LINK
Shucks, that's a bummer.
I would think the dependence on Windows 8 will hamper the rapid adoption of web sockets on Windows. Servers in particular can live out long lives before being set out to pasture. I'll keep my fingers crossed that http.sys gets an update in upcoming Windows
7 and Windows Server 2008 service packs!
Oct 28, 2011 08:15 PM|pmoskovi|LINK
This is a challenge not only because Windows 8 isn't available yet, but also because not everybody is going to upgrade to Windows 8 right away as it becomes available.
A possible solution is using .NET or Silverlight client libraries, provided by Kaazing.
The Kaazing WebSocket Gateway enables the HTML5 Communication protocol libraries in Silverlight and .NET Framework. Using these client libraries, you can enable WebSocket and Server-Sent Events in new or existing Silverlight or .NET applications. For example,
you can create a .NET Framework application that receives streaming news data through server-sent events.
Here you can learn more about it.
Nov 01, 2011 08:19 PM|Paul Batum|LINK
Peter, are these libraries interoperable with existing WebSocket implementations or can they only be paired with the Kaazing WebSocket Gateway? For example I'm wondering if a developer could use the Kaazing client libraries in a .NET 4.0 project on Windows
7 to connect to a WebSocket server running in WCF or ASP.NET on Windows 8.
Nov 21, 2011 02:02 AM|pmoskovi|LINK
Yes, these libraries are part of the Kaazing solution - you need to use the Kaazing WebSocket Gateway on the server side. You can, however write your business logic/client app in
.NET or Silverlight 4.0, and access the WebSocket-based app from Windows 7 (IE8, IE7, and even IE6).
Here's a post I wrote recently on the emulation/interoperability topic; hope you find it useful.