In my blog post from last summer I wrote about a prototype .NET implementation of two drafts of the WebSockets protocol specification - draft-hixie-thewebsocketprotocol-75 and draft-hixie-thewebsocketprotocol-76 - making its way through the IETF at that time. Since then, there have been a number of revisions to the protocol specification, and it is time to revisit the topic. Given the substantial demand for code to experiment with, we are sharing the Windows Communication Foundation server and Silverlight client prototype implementation of one of the latest proposed drafts of the WebSockets protocol: draft-montenegro-hybi-upgrade-hello-handshake-00.
You can read more about the effort and download the .NET prototype code at the HTML5 Labs site.
What is WebSockets?
WebSockets is one of the HTML 5 working specifications driven by the W3C to define a duplex communication protocol for use between web browsers and servers. The protocol enables applications that exchange messages between the client and the server with communication characteristics that cannot be met with the HTTP protocol.
In particular, the protocol enables the server to send messages to the client at any time after the WebSockets connection has been established and without the HTTP protocol overhead. This contrasts WebSockets with technologies based on the HTTP long polling mechanism available today.
For this early WebSockets prototype we are using a Silverlight plug-in on the client and a WCF service on the server. In the future, you may see HTML5 Labs using a variety of other technologies.
What are we making available?
Along with the downloadable .NET prototype implementation of the WebSocket proposed draft specification, we are also hosting a sample web chat application based on that prototype in Windows Azure at http://html5labs.cloudapp.net/WebSockets/ChatDemo/wsdemo.html. The sample web chat application demonstrates the following components of the prototype:
- The server side of the WebSocket protocol implemented using Windows Communication Foundation from .NET Framework 4. The WCF endpoint the sample application communicates with implements the draft WebSocket proposal.
- The client side prototype implementation consisting of two components:
- A Silverlight 4 application that implements the same draft of the WebSocket protocol specification.
The downloadable package contains a .NET prototype implementation consisting of the following components:
- A WCF 4.0 server side binding implementation of the WebSocket specification draft.
- A prototype of the server side WCF programming model for WebSockets.
- Silverlight 4 client side implementation of the protocol.
- .NET 4.0 client side implementation of the protocol.
- Web chat and stock quote samples.
Given the prototype nature of the implementation, the following restrictions apply:
- Only text messages under 126 bytes of length (UTF-8 encoded) can be exchanged.
- There is no support for web proxies in the client implementation.
- There is no support for SSL.
- Server side implementation limits the number of concurrent WebSocket connections to 5.
This implementation has been tested to work on Internet Explorer 8 & 9.
Why is this important?
Through access to emerging specifications like WebSockets, the HTML5 Labs sandbox gives you implementation experience with the draft specifications, helps enable faster iterations around Web specifications without getting locked in too early with a specific draft, and gives you the opportunity to provide feedback to improve the specification. This unstable prototype also has the potential to benefit a broad audience.
We want your feedback
As you try this implementation we welcome your feedback and we are looking forward to your comments!