Questions tagged [comet]

Comet is a generic term used to describe technology used to "push" data from a web server to connected web clients. In contrast to a "typical" web connection, in which the client must request data before the server can respond with that data, with Comet implementations, data can be pushed from the server without the client requesting said data. Comet can be implemented in a variety of ways: long-polling, callback-polling, forever-frame, etc.

Comet is a generic term used to describe technology used to "push" data from a web server to connected web clients. In contrast to a "typical" web connection, in which the client must request data before the server can respond with that data, with Comet implementations, data can be pushed from the server without the client requesting said data.

Comet can be implemented in a variety of ways:

Each has a variety of pros and cons, such as compatibility, cross-domain capabilities, and feature support (such as detecting disconnections, etc.).

Each Comet server is typically comprised of two major components:

  1. The server component. This component is responsible for handling the connections to the clients, and where much development effort is spent; small optimizations in this code make huge changes overall (for example, if one client stores 1 KB additional data, and you have 30,000 clients connected, that is an extra 30 MB of data that the server needs to store and track.
  2. The client component. This component is responsible for receiving data from the server component. The most common client is written in JavaScript, for use with a web browser, but clients can often be written in other languages as well, to facilitate integration with thick client applications. For example, Jetty has a client written in Java, and WebSync has clients written for Silverlight and standard .NET.

Common Language Implementations

There are a large amount of frameworks that could power a Comet based application. Most of these are standalone servers, with the exception of WebSync which runs on top of IIS.

  1. Java: Jetty, Rupy
  2. .NET: WebSync
  3. Python: Twisted
  4. Ruby: Event Machine
  5. JavaScript: Node.js
  6. Scala: Lift
  7. C++: CppCMS

More information

Some good resources for Comet include:

  1. http://ajaxpatterns.org/HTTP_Streaming
  2. http://cometdaily.org/
1111 questions
1184
votes
4 answers

What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?

I have tried reading some articles, but I am not very clear on the concepts yet. Would someone like to take a shot at explaining to me what these technologies are: Long Polling Server-Sent Events Websockets Comet One thing that I came across every…
user1437328
  • 15,546
  • 9
  • 34
  • 44
806
votes
17 answers

How do I implement basic "Long Polling"?

I can find lots of information on how Long Polling works (For example, this, and this), but no simple examples of how to implement this in code. All I can find is cometd, which relies on the Dojo JS framework, and a fairly complex server…
dbr
  • 165,801
  • 69
  • 278
  • 343
447
votes
6 answers

WebSockets protocol vs HTTP

There are many blogs and discussions about WebSocket and HTTP, and many developers and sites strongly advocate WebSockets, but I still can not understand why. For example (arguments of WebSocket lovers): HTML5 Web Sockets represents the next…
4esn0k
  • 9,789
  • 7
  • 33
  • 40
280
votes
5 answers

How does facebook, gmail send the real time notification?

I have read some posts about this topic and the answers are comet, reverse ajax, http streaming, server push, etc. How does incoming mail notification on Gmail works? How is GMail Chat able to make AJAX requests without client interaction? I would…
Billy
  • 15,516
  • 28
  • 70
  • 101
152
votes
4 answers

My Understanding of HTTP Polling, Long Polling, HTTP Streaming and WebSockets

I have read many posts on SO and the web regarding the keywords in my question title and learned a lot from them. Some of the questions I read are related to specific implementation challenges while others focus on general concepts. I just want to…
Software Guy
  • 3,190
  • 4
  • 21
  • 21
138
votes
18 answers

Is there some way to PUSH data from web server to browser?

Of course I am aware of Ajax, but the problem with Ajax is that the browser should poll the server frequently to find whether there is new data. This increases server load. Is there any better method (even using Ajax) other than polling the server…
Niyaz
  • 53,943
  • 55
  • 151
  • 182
114
votes
8 answers

Comet and jQuery

I've done some research into server push with javascript and have found the general consensus to be that what I'm looking for lies in the "Comet" design pattern. Are there any good implementations of this pattern built on top of jQuery? If not, are…
willurd
  • 11,745
  • 5
  • 28
  • 23
103
votes
8 answers

Comet implementation for ASP.NET?

I've been looking at ways to implement gmail-like messaging inside a browser, and arrived at the Comet concept. However, I haven't been able to find a good .NET implementation that allows me to do this within IIS (our application is written in…
Doron Yaacoby
  • 9,412
  • 8
  • 48
  • 59
99
votes
3 answers

Short-polling vs Long-polling for real time web applications?

I'm building a real-time web application As far as I know, the most popular choices are short-polling and long-polling. What are the advantages and disadvantages might there be for measuring one over the other?
Jeff
  • 14,365
  • 8
  • 30
  • 30
84
votes
11 answers

Using comet with PHP?

I was thinking of implementing real time chat using a PHP backend, but I ran across this comment on a site discussing comet: My understanding is that PHP is a terrible language for Comet, because Comet requires you to keep a persistent…
ryeguy
  • 65,519
  • 58
  • 198
  • 260
59
votes
3 answers

How is GMail Chat able to make AJAX requests without client interaction?

All HTTP responses require the client to initiate them, even those made using AJAX. But GMail's chat feature is able to receive messages from other users, even when I'm just sitting in my comfy computer chair watching but not interacting with the…
chat
  • 1,789
  • 3
  • 14
  • 11
54
votes
4 answers

Django / Comet (Push): Least of all evils?

I have read all the questions and answers I can find regarding Django and HTTP Push. Yet, none offer a clear, concise, beginning-to-end solution about how to accomplish a basic "hello world" of so-called "comet" functionality. First question (1): …
jMyles
  • 11,772
  • 6
  • 42
  • 56
52
votes
3 answers

Is there a server cost to using WebSockets?

I've been moving away from my comfort zone in PHP/MySQL because the syntax/encapsulation/procedural stuff can get frustrating. Last week, I started played around and followed some tutorials to use Node.js/Socket.IO to create a live chat application.…
M Miller
  • 5,364
  • 9
  • 43
  • 65
52
votes
7 answers

HTTP Response before Request

My question might sound stupid, but I just wanted to be sure: Is it possible to send an HTTP response before having the request for that resource? Say for example you have an HTML page index.html that only shows a picture called img.jpg. Now, if…
m_vdbeek
  • 3,704
  • 7
  • 46
  • 77
51
votes
6 answers

Servlet-3 Async Context, how to do asynchronous writes?

Problem Description Servlet-3.0 API allows to detach a request/response context and answer to it later. However if I try to write a big amount of data, something like: AsyncContext ac = getWaitingContext() ; ServletOutputStream out =…
Artyom
  • 31,019
  • 21
  • 127
  • 215
1
2 3
74 75