Is there a difference between long-polling and using Comet
Asked Answered
C

4

18

I am implementing a system where I need real-time updates. I have been looking at certain scenarios and among all was Comet. Implementing this I do not see any way this is different from traditional long-polling.

In both cases you have to send a request, and then the server send a response back. In the browser you interpret the response and then you start a new request.

So why should I use comet if in both cases I need to open and close connections.

Crossbow answered 3/4, 2010 at 9:46 Comment(2)
READ THIS: cometdaily.com/2007/12/11/…Denunciate
The above (excellent) link is dead. Wayback Machine has it here.Tace
C
12

Some Comet techniques don't require that you constantly open new requests (the chunked hidden iframe, for instance), the idea being to hold the request open and have the server periodically sending data. But this doesn't work well across all major browsers without (as one Wikipedia contributor delicately put it) negative side-effects, hence the long-polling technique. More in the linked article.

Chartist answered 3/4, 2010 at 9:58 Comment(2)
This is what I thought. Because in this secion en.wikipedia.org/wiki/Comet_(programming)#Streaming it looks like a streaming connection is something comet can do. But i am searching trough every single example found on the net and can not find a single working streaming connection.Crossbow
+1, also see cometdaily.com/2007/12/18/latency-long-polling-vs-forever-frame and cometdaily.com/2007/11/16/more-on-long-polling to note that there's really no practical difference between long-polling and the "forever frame" idea.Macknair
P
11

As mentioned by Marcelo, Comet is usually used to describe any techniques for "HTTP streaming", including long-polling. In some cases, Comet might also refer more specifically to the Bayeux Protocol. For instance, the jQuery Comet plugin is of this protocol. From the Bayeux website:

Delivery of asynchronous messages from the server to a web client is often described as server-push. The combination of server push techniques with an Ajax web application has been called Comet. CometD is a project by the Dojo Foundation to provide multiple implementation of the Bayeux protocol in several programming languages.

Bayeux is an attempt to standardize a publish/subscribe protocol using Comet techniques, allowing for vendors of client and server side libraries to create interoperable components.

Padilla answered 3/4, 2010 at 10:3 Comment(2)
Can you achieve http streaming with jQuery Comet. Thus with only one request and multiple responses. I see many websites that refer to the theoretical technique, but I can not find a tiny example appCrossbow
One request with multiple response should be possible using an <iframe> as transfer media. I am not sure if the jQuery plugin supports this optional part of the Bayeux protocol.Spoor
H
7

Comet is an umbrella term for a wide range of asynchronous update techniques, of which long-polling is just one.

Hoggish answered 3/4, 2010 at 9:54 Comment(1)
Ok i understand this. But there is a comet plugin for jquery, which can be used with a comet server. What benefits does this have over traditional long-polling. I can not find any recourses where something else is used other than long-polling.Crossbow
S
0

If you want to push insteal of pulling, you can use JPE.

Socha answered 3/4, 2010 at 10:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.