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
10
votes
2 answers

socket.io and .Net socket server

Excuse me if the question sounds silly but I have to ask. Is there a server side alternative to Node.js written in C#? I need a client framework to fully utilize Web Sockets but AFAIK IE doesn't support Web Sockets and nor will it support in it's…
Élodie Petit
  • 5,774
  • 6
  • 50
  • 88
10
votes
4 answers

How does Gmail do comet on Opera?

I would like to know how Gmail (or anyone else) does comet on Opera. Here is what I know so far from my experiments. It doesn't use the event-source tag which is broken in Opera 10.51. It doesn't use iframe which displays a spinning throbber and a…
Unknown
  • 45,913
  • 27
  • 138
  • 182
10
votes
1 answer

Can Websockets Work On Mobile Phones?

I'm currently thinking about creating a soft realtime mobile phone webapp, but when I started researching websockets, I found a load of scare stories about websocket connections dropping out on mobile phones: WebSockets over a 3G…
Charlie
  • 4,197
  • 5
  • 42
  • 59
10
votes
4 answers

Is Http Streaming Comet possible in Safari?

By HTTP Streaming Comet, I mean the "forever iframe" / "forever xhr" variations that don't close the connection after data has been pushed from the server, as opposed to standard polling and long polling which close and resend a new request for…
Leo
  • 2,860
  • 3
  • 24
  • 21
9
votes
1 answer

Does facebook use comet or long polling for getting new stream and messages?

I would like to know if there are any code references that I can follow to write a very simple example. Many posts or websites just talk about the technology.
Mark K.
  • 1,969
  • 2
  • 16
  • 15
9
votes
1 answer

GWT and WebSocket / Push data from server to GWT client

Is there any good library which supports WebSockets and is compatible with GWT? Ideally, the library would support WebSockets as well as a fallback for browsers which don't support WebSocket, e.g. a comet-like approach or polling. I'm currently…
Bob
  • 5,510
  • 9
  • 48
  • 80
9
votes
2 answers

How many child_processes should I fork() in node.js?

My question is quite simple. though, it may require different variable to be answered (i guess) I'm playing around with node.js and I'm thinking of how to use it in a multi core architecture. Latest version provides child_process.fork()and…
ArtoAle
  • 2,939
  • 1
  • 25
  • 48
9
votes
3 answers

Node.JS: How to create a HTTP Chat Server?

With the Net Stream Object with TCP works great (as presetend in the node.js introduction video), but how should I do this in HTTP? Is there a way to access sockets/clients within an http.createServer() ? Or what's the method to do it? I tried to…
Adam Halasz
  • 57,421
  • 66
  • 149
  • 213
9
votes
4 answers

Streaming with Node.js, or any other Comet solution

I'm trying to build a streaming solution for an internal app, but am drawing blanks for a solution to get past a roadblock. Currently, in my working example, I'm using APE, but due to restrictions I can't have any foreign running processes on the…
A Wizard Did It
  • 3,614
  • 4
  • 28
  • 32
9
votes
2 answers

Pressing Escape under Firefox kills my Ajax requests. I'd like to prevent this

I'm developing a web application which requires long-running Ajax requests. Unfortunately, under Firefox, pressing Escape during a request has the drawback of killing the request and any information it was holding. This is rather annoying, as this…
Yoric
  • 3,348
  • 3
  • 19
  • 26
9
votes
9 answers

Ajax "Is there new content? If so, update page" - How to do this without breaking the server?

It's a simple case of a javascript that continuously asks "are there yet?" Like a four year old on a car drive.. But, much like parents, if you do this too often or, with too many kids at once, the server will buckle under pressure.. How do you…
Alexander Morland
  • 6,356
  • 7
  • 32
  • 51
9
votes
4 answers

Asynchronous COMET query with Tornado and Prototype

I'm trying to write simple web application using Tornado and JS Prototype library. So, the client can execute long running job on server. I wish, that this job runs Asynchronously - so that others clients could view page and do some stuff…
grundic
  • 4,641
  • 3
  • 31
  • 47
8
votes
2 answers

WCF comet and threads

I'm trying to use WCF to implement a comet style server push to an ajax web application. In my WCF service, I've implemented a WaitForEvents method that calls Monitor.Wait to suspend the thread until new data arrives. At that point, the Monitor is…
vincent
8
votes
2 answers

Long Polling Options: Nginx, PHP, Node.js

I'm designing a long-polling app to broadcast small changes very rapidly to, possibly, a large number of users. The app will run in tandem with a website running a fairly standard cms. They'll both be running on one server, and to begin with so will…
thelastshadow
  • 3,406
  • 3
  • 33
  • 36
8
votes
5 answers

How to implement event listening in PHP

here is my problem: I have a script (let's call it comet.php) whic is requsted by an AJAX client script and wait for a change to happen like this: while(no_changes){ usleep(100000); //check for changes } I don't like this too much, it's…
ArtoAle
  • 2,939
  • 1
  • 25
  • 48