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
14
votes
3 answers

How does Play!'s Comet support work?

I saw the Akka module's description says that Play has great Comet support, but I've never used Comet before and I can't find any mention of it in Play's documentation. How does it work in Play? I spent a few hours over two days figuring this out…
Brad Mace
  • 27,194
  • 17
  • 102
  • 148
14
votes
2 answers

AJAX Polling Frequency - To long poll or not to long poll?

I'm building a component of a web page that needs relatively constant database polling. I can see two different approaches for this, and I'm wondering if one of them is better than the others, or if I'm missing a third option. 1) Send off an AJAX…
Derek
  • 1,196
  • 11
  • 32
14
votes
5 answers

Writing a chat application

I'm wondering what's the right way to code a chat application for thousands of users. I'm just confused how will I be able to ping the server using AJAX every second or maybe less and check if there are new records in MySQL, etc with an acceptable…
Isamtron
  • 613
  • 2
  • 8
  • 13
14
votes
1 answer

WebSocket and CGI/FastCGI/SCGI protocols

I'm looking for resources about interaction between client side web socket, web server and real application backend that works behind CGI, FastCGI or SCGI protocols. It seems that this is impossible at this point as: Request length is specifically…
Artyom
  • 31,019
  • 21
  • 127
  • 215
14
votes
1 answer

How does GMail implement Comet?

With the help of HttpWatch, I tried to figure out how GMail implements Comet. I login in to GMail with two accounts, one in IE and the other in Firefox. Chatting in GTalk in GMail with some magic words like "WASSUP". Then, I logoff both GMail…
Morgan Cheng
  • 73,950
  • 66
  • 171
  • 230
14
votes
3 answers

How To Implement ReverseAJAX (Comet) in ASP.Net MVC

How could I implement a Comet architecture in a ASP.Net MVC?
SDReyes
  • 9,798
  • 16
  • 53
  • 92
14
votes
5 answers

Long polling with NSURLConnection

I'm working on an iPhone application which will use long-polling to send event notifications from the server to the client over HTTP. After opening a connection on the server I'm sending small bits of JSON that represent events, as they occur. I…
pix0r
  • 31,139
  • 18
  • 86
  • 102
14
votes
2 answers

Cross-browser implementation of "HTTP Streaming" (push) AJAX pattern

Client request web page from server. Clent then requests for extra calculations to be done; server performs series of calculations and sends partial results as soon as they are available (text format, each line contains separate full item). Client…
Jakub Narębski
  • 309,089
  • 65
  • 217
  • 230
13
votes
6 answers

Choosing and deploying a comet server

I want to push data to the browser over HTTP without killing my django/python application. I decided to use a comet server, to proxy requests between my application and the client (though I still haven't really figured it out properly). I've looked…
skyronic
  • 1,577
  • 1
  • 11
  • 15
12
votes
8 answers

How to display HTML to the browser incrementally over a long period of time?

Do I need to pass back any HTTP headers to tell the browser that my server won't be immediately closing the connection and to display as the HTML is received? Is there anything necessary to get the HTML to incrementally display like flush()? This…
cgp
  • 41,026
  • 12
  • 101
  • 131
12
votes
3 answers

Python+Tornado vs Scala+Lift?

I'm looking to start a Google Maps based web application. My initial thoughts are that in the first phase the focus should be on the front-end, and the backend should be easy to write and to prototype, and should aid as much as possible the…
florin.bunau
  • 1,875
  • 3
  • 17
  • 25
12
votes
6 answers

longpoll XHR vs iframe

I'm implementing typical server-push (comet) application. I'm choosing between two options: the longpoll XHR and iFrames. What are pros and cons of these? I know about the cross-site restrictions and that iFrame is pretty heavyweight component...…
Juriy
  • 5,009
  • 8
  • 37
  • 52
12
votes
2 answers

Twisted and Websockets: Beyond Echo

In my ongoing curiosity about websockets, I'm noticing a trend: The "hello world" of the websocket universe, at least at the moment, seems to be "echo" functionality. That is, the demonstrated application is typically, "I send something, I receive…
jMyles
  • 11,772
  • 6
  • 42
  • 56
12
votes
1 answer

out of this world Comet programming and a web-based chat

Current Project Setup I've been working on a web-based chat, similar to Facebook chat. At the current state, I listen for incoming chats and check for new messages in an existing chat is by doing... setTimeout(function() { listenForIncomingChat() },…
Hristo
  • 45,559
  • 65
  • 163
  • 230
12
votes
3 answers

How to check the number of open connections in node.js?

I have a machine running node.js (v0.1.32) with a tcp server (tcp.createServer) and a http server (http.createServer). The http server is hit by long polling requests (lasting 50 sec each) from a comet based application on port 80. And there are tcp…
Sharief Shaik
  • 1,064
  • 5
  • 12
  • 26