From several years the paradigm of request/response using HTTP has dominated the Web. It was around 2005, that Ajax added more dynamicity and allowed request/response to run in the background. However, it required continuous polling to the server to get data resulting in an overhead on the server. HTTP by design is an asymmetric protocol i.e. a client can send a request to the server anytime but the server cannot send response data at its will. It can send updates only when a request is made by the client.

Lately, there has been a lot of buzz around HTML5 WebSockets, it defines a full-duplex, bi-directional communication channel and operates through a single socket over the web. The HTML5 WebSockets provides a true standard for building scalable and real time web applications. Here there is an open connection between the client and server and both can start sending data any time.

How it works:

The client can establish a connection to the server by invoking the WebSocket constructor:

var wsconnection = new WebSocket(‘ws://server_name/’);

The WebSocket constructor takes the URL of the server to which the connection has to be established as an argument. Notice the new schema ws: in the URL. WebSockets use ws:// and wss:// (analogous to https://) URLs as identifiers. The overhead is very less since the interaction doesn’t include request and response headers to be set. Once a connection has been established between the two parties the client can send and receive data from the server using various event handlers:

connection.onopen = function() {
    console.log(‘Connection established’);
connection.onmessage = function(evt) {
    console.log(‘Message ‘ +;
connection.onerror = function(err){
console.log(‘Error occurred ‘ + err);


The biggest challenge is to provide a server side infrastructure to handle WebSocket requests so that the server can start pushing data to its clients at certain events. The other challenge is that it should work on all the browsers. Well, most of the modern browsers support it natively, but it would fail on older browsers.


ColdFusion!! ColdFusion Zeus would address this problem and help you build real time applications without having to bother about the server side infrastructure nor the browser support. It would fall back to Flash on browsers that don't support WebSockets natively. More content regarding new features in ColdFusion Zeus will follow, so stay tuned.

Sagar Ganatra.

3 Comments to “HTML5 WebSockets, it's coming”

  1. Ben Nadel
    Awesome!!!!! Push notifications is going to be huge!
  2. Robbiegod
    This sounds great, so when can we see a working demo?
  3. Sagar Ganatra
    Soon. Very soon...

Leave a Comment

Leave this field empty: