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).

Resources

Comet

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

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry. ES6 Training in Chennai

    ReplyDelete