The Websocket protocol, still only a draft standard, is a part of the HTML 5 draft standard.  The protocol is being designed to allow web-based applications to communicate with server side services in an asynchronous manner.

Whether Websockets supersede other comparable technologies such as CometD/Bayeux protocol as some have suggested (Joe Armstrong, father of Erlang: WebSockets will kill Comet)  or do not go far enough (Greg Wilkins, co-creator of Jetty and the Bayeux protocol:  WebSocket specification needs improving) I would not want to hazard a guess.

It’s even possible that Websockets end up complimenting CometD in CometD version 2, as discussed here – but as noted by Greg Wilkins there are still issues left to resolve such as Keep Alives with a suggestion for a future version to support timeout discovery and Timeouts with suggested messages that can be used to distinguish between a network failure and an orderly close as the user leaves the page.

Anyway, considering that Websockets and HTML 5 is being sponsored by Google, Apple and others at the WhatWG working group and there are already HTML 5 capable browsers (Chrome, Safari) starting to  support the WebSocket protocol, I, in an attempt to better understand the technologies, decided to download Jetty and follow a simple Websocket Chat example.  After a few minutes I had the simple application up and running using Jetty and the Google Chrome browser.  However, I ran into an issue when trying to run the simple app using the Maven Jetty plugin, getting the following exception:

java.lang.NullPointerException        at
org.eclipse.jetty.websocket.WebSocketFactory.upgrade(WebSocketFactory.java:92)        at
org.eclipse.jetty.websocket.WebSocketServlet.service(WebSocketServlet.java:60)        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:820)        at
org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)        at
...
This I resolved by adding the Jetty-websocket library as a dependency to the plugin:
<plugin>
	<groupId>org.mortbay.jetty</groupId>
	<artifactId>jetty-maven-plugin</artifactId>
	<version>7.0.2.RC0</version>
	<configuration>
		<scanIntervalSeconds>5</scanIntervalSeconds>
	</configuration>
	<dependencies>
		<dependency>
			<groupId>org.eclipse.jetty</groupId>
			<artifactId>jetty-websocket</artifactId>
			<version>7.0.2.RC0</version>
		</dependency>
	</dependencies>
</plugin>

Advertisement