I’ve been playing with Web Sockets using Google’s Chrome browser. Web Sockets, put simply, is a really nice way for a web application to talk to a remote server and allows the remote server to talk back. There are currently various ways of doing this with using Comet. But let’s be honest. Comet is a total hack. Web Sockets, on the other hand, is a very elegant solution.
I submitted a patch to the Netty project for supporting the Web Sockets protocol.
To demonstrate how to use this patch, I’ve created a little demo. This demo consists of a simple web page for sending data to the server using the Web Sockets API JavaScript API, and a simple Netty server for serving up the web page and handling the data send over the Web Socket protocol. You can download this demo from, http://people.apache.org/~mheath/websocketexample.zip. To compile it, you will need that latest version of Netty from Subversion and apply the patch I mentioned earlier.
2 Responses
Stephen Bannasch
December 25th, 2009 at 12:12 pm
1Hi Mike,
Thanks for sharing your websockets patch.
I haven’t used netty before so this may be a silly question.
I got netty working with your patch. When I first open the connection to http://localhost:8080 I get this error in the console:
java.nio.channels.ClosedChannelException
Is that normal?
You can see the full console output here: http://gist.github.com/263720
I’m running this with Chromium 4.0.281.0 (35262) on MacOS 10.5.8.
Mike Heath
January 29th, 2010 at 9:56 am
2Stephen,
So the java.nio.channels.ClosedChannelException you were seeing is something I was seeing too. I didn’t take too much time to look into it. When Trustin applied my patch to Netty, I tried out his examples and wasn’t seeing any exceptions.
The exception was coming from downloading the test HTML page so I could have been doing something wrong there. The Web Sockets side of things seamed to be working just fine.
-Mike
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
Archives
Links
Meta
Calendar