Is Comet deprecated now with Server-Sent Events and WebSocket?

or are Server-Sent and WebSocket events replacing Comet methods?

+15
websocket comet server-sent-events
Aug 22 '12 at 17:40
source share
4 answers

Comet is a set of technology principles / communication patterns that are typically implemented using an HTTP poll. It allows the server to send data to the browser on demand (i.e., Press the server). Existing comet implementations require complex client-side Javascript and server-side support (for long requests).

Server Events is a standard (HTML5) browser API for enabling this type of server request on demand. You can think of Server-Sent Events as what was done using sophisticated Javascript and push it into the browser.

WebSockets allows the browser to establish a permanent full-duplex / bi-directional connection to a server that supports WebSocket. It does not require the client to continue to periodically send HTTP requests to the server in order to maintain a connection, as with AJAX / long-poll. Once the connection is established, the overhead per message is very low (a few bytes) compared to the overhead with the normal HTTP / HTTP protocol. You can use WebSockets to push the server efficiently, but this is just one application.

There are also libraries that are built on the AJAX / comet / WebSockets transport layer to provide features such as session management, channels, translation, pubsub, etc. CometD is an example of this. Another popular example: Socket.IO . Both support WebSockets if they are available for basic transport, but also support standard AJAX / long-poll if WebSockets is not available.

+11
Aug 22 '12 at 18:58
source share

I approach this answer both with terminology and from a historical point of view.

As I wrote in this other answer , we can use one of several umbrella terms to refer to the set of technologies available for sending events from the web server to the web client asynchronously (and vice versa). The term " Push Technology " has been used for fifteen years (for the short history of Push Technology you can see this old white paper I wrote many years ago - full disclosure: I am the creator of Lightstreamer). Now the term Web streaming is gaining strength among IT analysts (see Gartner, Cool Vendors in Application and Integration Platforms, 2012) by Massimo Pezzini and Jess Thompson, April 11, 2012).

An important aspect is that we are talking about web communications, that is, the use of web protocols. There are many protocols and messaging technologies that are not websites (for example, most MOMs), and we do not consider them as part of Push (or web streaming) technology.

In doing so, you can distinguish between two subcategories of Push technology (or web streaming):

  • HTTP
  • WebSockets Basics

Both HTTP and WebSockets are web protocols.

If you explode HTTP-based push mechanisms, you can determine:

  • HTTP streaming
  • Long HTTP polling
  • HTTP poll

Traditionally, the term " Comet " (superimposed on 2006 by Alex Russell) refers to both streaming HTTP and HTTP polling. But keep in mind that the first implementations of HTTP streaming will return to 2000 , long before the term Comet was coined (examples are buttons and Lightstreamer).

Now WebSockets simplify the implementation of web streaming, especially for the "reverse" channel (messages sent from the browser to the server). For a more detailed explanation of the features of the reverse channel via HTTP, see the final part of this article that I wrote for CometDaily: http://cometdaily.com/2011/07/06/push-technology-comet-and-websockets-10-years- of-history-from-lightstreamers-perspective /

As Phil noted, the comet is still necessary and will probably continue for several more years, since not only old browsers (including IE9, which do not support WebSockets ...) work around it, but also endless parts of network intermediaries that donโ€™t speak WS. For example, we saw that some mobile operators in some countries (for example, Vodafone Italy) support WSS, but block WS. Thus, a world without cometary โ€œhacksโ€ is still far away ... And let me add to my personal note that I never liked the term โ€œhackโ€ applied to comets (or, from a more correct historical point, viewing applied to an HTTP stream and a long HTTP poll). Working on these methods for 12 years, I can say that we managed to refine them so much that they became a full-blown technology, completely reliable and used every day in many critical production scenarios (in the field of finance, aerospace, and military, to name a few industries )

Now imagine a world where WebSockets are universally supported and a comet is no longer needed. What do you get exactly? Well, just bidirectional transport, nothing more ... At the top you need to build everything: a messaging protocol (possibly based on pub / sub), a server-side interface to talk to your server code, and a good set of optimization methods and algorithms flow control, including bandwidth management, data aggregation, automatic throttling, delta delivery, etc. Itโ€™s good that both messaging protocols and optimization mechanisms are already implemented by good Comet solutions. Thus, expanding legacy Comet servers to support WebSocket is a natural evolution that all of our vendors have implemented.

So, in the near future, WebSockets may make Comet transport obsolete, but it will need to suck all the higher levels already implemented and well tested on traditional Comet servers.

+19
Aug 22 '12 at 10:11
source share

Initially, I thought WebSockets implements a comet. They are not an alternative . However, after some discussion, I was later corrected and convinced Alex Russell , creator of "Comet", that this is not so.

The comet, as @kanaka says, is a set of principles for modeling bidirectional communication between a client and a server (server push is half the solution and is now provided by Server-Sent and Source Source API events).

However, comet solutions are hacks because they work inconsistently in web browsers. For this reason, Alex Russell says:

Next, are Web sockets a form of comet? Or is a comet just an HTTP hack? I am going to go for the last definition. The phrase and khaki should probably go to sunset together. For example, I welcome our non-HTTP servers in real time. To the extent that we can forget about old browsers (and God knows that I am doing my bit: http://google.com/chromeframe ), we can all have a board with "web sockets" and the need for some kind of a specific umbrella goes away.

So let's focus on this: how do we get users to a brilliant new browser? What suggestion can we offer them about the wealth and real-time experience that a WebSockets-based application can provide? Comet about the past. Let's make the future real.

I'm with Alex on this now. However, Comet-HTTP solutions do not expire until:

  • Browser support is 100% and we do not need backups for <IE10. I do not believe that the problems of Firefox, Safari and Opera will be a problem. There may be a small percentage of users who ignore auto-update hints for browsers such as Firefox, but not many.
  • Manufacturers of antivirus software (such as Avast!) Are starting to support HTML5 web technologies and stopping their software, preventing them from connecting.
  • Some Internet infrastructure has been updated to support WebSockets. In my experiences with WSS through port 443 (a secure connection to WebSocket), it usually means that connections make their way through firewalls and proxies, but we want WS over port 80 to always be supported.
+9
Aug 22 '12 at 19:18
source share

While WebSocket provides at the most fundamental level a way of two-way communication between client and server in the context of Web and HTTP, it is a simple form of communication.

The comet provides more functionality on top of WebSocket (in fact, cometd even supports websocket), for functions:

  • like publishing / subscribing and communication channels
  • abandon old methods of communication with clients and server when websocket is unavailable
0
Aug 22 '12 at 18:17
source share



All Articles