Tuesday, November 22, 2011

Long Running HTTP

Typically, an HTTP request is made and returns more or less immediately. But what if you want to keep the connection open so that the server can push data to the client on demand? Traditionally, this is impossible to do, hence the 'pull' nature of web browsers.

There is a solution, however. HTTP allows for a 'chunked' connection. This basically says, keep listening for some unknown amount of data until the end command is sent. This is referred to as long running HTTP, reverse ajax, comet, HTTP push, etc. This allows for real-time communication between the client and server. Unfortunately, with a traditional web server like IIS, these long running requests hold on to their resources and eventually bog down or crash the server.

There are solutions that exist, most of which suggest implementing a stand alone server. There is a protocol called Bayeux that many implementations use that would allow a proprietary client or server work with other proprietary systems implementing it. Others write their own implementations.

In short, it is possible to have real-time communications over HTTP. More and more web applications are beginning to adopt this technique (you have probably used one without knowing it). The major downfall, currently, is the sparseness of open and stable out of the box implementations (especially in .Net and for IIS).



Bayeux Protocol

CometD - Javascript Bayeux client backed by Dojo (Bayeux creator) with jQuery bindings

aspComet - Free open Bayeux server

Pokein - Paid .Net server and jQuery friendly client custom implementation (not Bayeux)

WebSync - Paid IIS .Net Bayeux server