views:

730

answers:

6

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?

+2  A: 

Yes, because "soon" is a very slippery term. Many web shops still have to support IE6.

No, because a rash of comet frameworks and servers has emerged in recent times that will soon make it largely unnecessary for you to get your hands dirty in the basement.

Yes, because "soon" is a very slippery term...

Marcelo Cantos
which frameworks are you referring to? but aren't today's available frameworks only using comet?
never_had_a_name
+1. IE9 is years away.
You
@ajsie: [Today's frameworks](http://cometdaily.com/maturity.html) support asynchronous server-push to the browser. Many of them support HTML 5 already, with fallback to comet, so you don't really have to care how they achieve it.
Marcelo Cantos
@marcelo. but i dont get it. those "frameworks" are just servers? i still have to write the code for handling server push?
never_had_a_name
@ajsie: No, they provide client bits.
Marcelo Cantos
@marcelo. do you know if there is some framework for ruby?
never_had_a_name
+2  A: 

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.

Daniel Vassallo
-1; while WebSockets are capable of replacing the *client* side solution to these problems, it's not going to replace the *server* side need, and until 1) all major browsers and 2) all http proxies support it, it's not going to be obsolete; even then, I expect the "hacks" will remain around for backwards compatibility
jvenema
@jvenema: Yes, I agree with your answer. Nevertheless, my answer is not to be considered an exhaustive explanation of the topic, even though it was selected as accepted by the OP. I also believe that the "comet hacks, et al" will remain around for long.
Daniel Vassallo
@jvenema: I also removed the "Yes," from my answer, which I think was misleading :) ... I didn't intend to say that comet will become obsolete soon, but that WebSockets attempt to improve on the concept of bi-directional communication.
Daniel Vassallo
Fair; I upvoted your comments because you're correct about your response, but I've gotta leave the downvote on the answer because it was accepted, but isn't really correct ;)
jvenema
+1  A: 

In the medium term websockets won't replace comet solutions not only because of lack of browsers support but also because of HTTP Proxies. Until most of HTTP Proxies will be updated to support websockets connections, web developers will have to implement alternative solutions based on comet techniques to work in networks "protected" with this kind of proxies.

In the short/medium websockets will be just an optimization to be used when available, but you will still need to implement long-polling (comet) to rely on when websockets are not available if you need to make your website accessible for a lot of customers with networks/browsers not under your control.

Hopefully this will be abstracted by javascript frameworks and will be transparent for web developers.

gustavogb
Could u elaborate some more.
never_had_a_name
Sure, I have elaborated more my point, is it ok now?
gustavogb
+3  A: 

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

Checkout out Orbited and Hookbox.

Salman Haq
+4  A: 

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.

jvenema
A: 

Charter for the [working group] working group tasked with websockets, BiDirectional or Server-Initiated HTTP (hybi):

Description of Working Group

HTTP has most often been used as a request/response protocol, leading to clients polling for new data, or users hitting the refresh button in their browsers. Recent web applications are finding ways to communicate with web servers in realtime, pushing data from the server-side to the client as soon as it is available. However, these applications at present can only use a variety of HTTP mechanisms (e.g. long polling requests) to communicate with web servers bidirectionally.

The Hypertext-Bidirectional (HyBi) working group will seek standardization of one approach to maintain bidirectional communications between the HTTP client, server and intermediate entities, which will provide more efficiency compared to the current use of hanging requests.

HTTP still has a role to play; it's a flexible message oriented system. websockets was developed to provide bidirectionality and avoid the long polling issue altogether. [it does this well]. but it's simpler than http. and there's a lot of things that are useful about http. there will certainly be continued progress enriching http's bidirectional communication, be it comet or other push technologies. my own humble attempt is [http://github.com/rektide/pipe-layer].

rektide