Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML 5 Websockets will replace Comet?

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?

like image 442
never_had_a_name Avatar asked Aug 08 '10 23:08

never_had_a_name


3 Answers

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.

like image 170
jvenema Avatar answered Oct 14 '22 12:10

jvenema


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

WebSockets are capable of replacing Comet, AJAX, Long Polling, and all the hacks to workaround the problem when web browsers could not open a simple socket for bi-directional communications with the server.

Is there a reason why I should learn how to implement comet when WebSockets soon will be available in all major browsers?

It depends what "soon" means to you. No version of Internet Explorer (pre IE 9) supports the WebSockets API yet, for example.


UPDATE:

This was not intended to be an exhaustive answer. Check out the other answers, and @jvenema's in particular, for further insight into this topic.

like image 12
Daniel Vassallo Avatar answered Oct 14 '22 12:10

Daniel Vassallo


Consider using a web socket library/framework that falls back to comet in the absence of browser support.

Checkout out Orbited and Hookbox.

like image 3
Salman Haq Avatar answered Oct 14 '22 11:10

Salman Haq