HTML 5 Websockets will replace Comet?

never_had_a_name picture never_had_a_name · Aug 9, 2010 · Viewed 8.8k times · Source

It looks like Websockets in HTML 5 will become a new standard for server push.

Does that mean the server push hack called Comet will be obsolete?

Is there a reason why I should learn how to implement comet when Websockets soon (1-2 years) will be available in all major browsers?

Then I could just use Beaconpush or Pusher instead till then right?

Answer

jvenema picture jvenema · Aug 11, 2010

There are 2 pieces to this puzzle:

Q: Will the client-side portion of "comet" be necessary?

A: Yes. Even in the next 2 years, you're not going to see full support for WebSockets in the "major" browsers. IE8 for example doesn't have support for it, nor does the current version of FireFox. Given that IE6 was released in 2001, and it's still around today, I don't see WebSockets as replacing comet completely anytime soon.

Q: Will the server-side portion of "comet" be necessary?

A: Yes. Comet servers are designed to handle long-lived HTTP connections, where "typical" web servers do not. Even if the client side supports WebSockets, the server side will still need to be designed to handle the load.

In addition, as "gustavogb" mentioned, at least right now WebSockets aren't properly supported in a lot of HTTP Proxies, so until those all get updated as well, we'll still need some sort of fallback mechanism.

In short: comet, as it exists today, is not going away any time soon.

As an added note: the versions of WebSockets that currently ARE implemented in Chrome and Safari are two different drafts, and work on the "current" draft is still under very heavy development, so I don't even believe it is realistic to say that WebSockets support is functional at the moment. As a curiosity or for learning, sure, but not as a real spec, at least not yet.

[Update, 2/23/11]

The currently shipping version of Safari has a broken implementation (it doesn't send the right header), Firefox 4 has just deprecated WebSockets, so it won't ship enabled, and IE9 isn't looking good either. Looks like Chrome is the only one with a working, enabled version of a draft spec, so WebSockets has a long way to go yet.