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

Is "long polling" the most efficient way to create a Web Real Time App?

I want to create an application like this: http://collabedit.com/ What is the most efficient way to create this real time application? Flash? Long polling? Http Streaming? or something else? Thanks ;)
xRobot
  • 25,579
  • 69
  • 184
  • 304
12
votes
3 answers

Simplest way to implement backend server for multiplayer JavaScript game? (COMET/longpolling)

I've been writing a game in JavaScript, and it's time to make it multiplayer. I would like to use AJAX long-polling to get the current game state, as well as implement the lobby. The server just needs to perform basic functions, like store the…
Zack Burt
  • 8,257
  • 10
  • 53
  • 81
11
votes
2 answers

Servlet 3 Async task on Tomcat 7

I'm trying to implement Simple chat using Servlet 3.0 and Comet pattern based on its async support. I'm inspired by this article: http://www.javaworld.com/javaworld/jw-02-2009/jw-02-servlet3.html?page=3 My servlet looks like…
danny.lesnik
  • 18,479
  • 29
  • 135
  • 200
11
votes
2 answers

Is Comet still immature?

I'm thinking of writing a realtime web app that would need to be able to push messages to the browser. When I first read about Comet, people seemed to consider it a brittle and immature approach due to weak browser support. Today, it seems to be an…
Alex
  • 113
  • 4
11
votes
4 answers

Real-time bi-directional JSON-RPC communication over HTTP

I am building a JSON-RPC server that accepts requests over HTTP. I would like to support bi-directional communication (both client and server can send requests), the specific use case being a publish/subscribe architecture where a client sends a…
Felix Lange
  • 1,572
  • 11
  • 15
11
votes
4 answers

Node.js vs Java for Comet application

We look to build a high-performance, scalable Comet server, and thought first about using Java Grizzly with GlassFish. But after some research, we see that Node.JS is taking rapidly as the preferred choice due to extreme simplicity, and claimed…
SyBer
  • 5,407
  • 13
  • 55
  • 64
11
votes
6 answers

Is there an alternative of ajax that does not require polling without server side modifications?

I'm trying to create a small and basic "ajax" based multiplayer game. Coordinates of objects are being given by a PHP "handler". This handler.php file is being polled every 200MS, by using ajax. Since there is no need to poll when nothing happens, I…
Tom
  • 8,536
  • 31
  • 133
  • 232
11
votes
5 answers

Long held AJAX connections being blocked by Anti-Virus

Ok, this is downright bizarre. I am building a web application that relies on long held HTTP connection using COMET, and using this to stream data from the server to the application. Now, the problem is that this does not seem to go well with some…
jeffreyveon
  • 13,400
  • 18
  • 79
  • 129
11
votes
1 answer

How scalable is the Lift framework's comet/reverse ajax?

I recently learned scala and about to start working/learning Lift framework. Going through the Features and getting started with the framework, I had seen some amazing capabilities of the framework including the reverse ajax and comet. Earlier in my…
Teja Kantamneni
  • 17,402
  • 12
  • 56
  • 86
11
votes
2 answers

How can I check for live updates without using setInterval/timeout?

Building a social network, I'm trying to fetch live notifications. Currently, the site sends an AJAX request every few seconds using setInterval. It looks something like this: setInterval ( function(){ url = base_dir+"/ajax/file.php"; data =…
talhof9
  • 135
  • 3
  • 9
11
votes
3 answers

Comet & PHP: How to use Comet with a PHP Chat System?

I have to build a simple chat system in PHP using Comet. I don't know what would be the best approach to this project. What is the best technique (cross-browser would be nice) to use, and how to implement it? What libraries can I use that already…
Cristian Toma
  • 5,662
  • 2
  • 36
  • 43
11
votes
3 answers

So... ASP.NET MVC and WebSockets?

I have an application in MVC 3 and I'm looking to add WebSockets (with fallback to Comet) to it. I've researched a bit and I found out the Comet part is pretty straightforward and I'd much rather do it myself. Just AsyncControllers and a pretty…
bevacqua
  • 47,502
  • 56
  • 171
  • 285
11
votes
4 answers

Realtime server push with Socket IO (or Strophe.js), XMPP and Django

I have a couple of Android and iOS native mobile application that I wrote which connect directly to an XMPP server that I host. They push and pull realtime data through XMPP. I also use some of the XMPP XEP extensions. For other operations, I have a…
rburhum
  • 1,611
  • 2
  • 17
  • 33
10
votes
5 answers

Options for real-time web notifications and updates using Comet/XMPP vs WebSocket technologies on a Microsoft stack?

I am scoping out the architectural options for a project that will render live updates (like Facebook) of user activities - logins, photos, etc. Two main UI components of this are an auto-updating scrolling area where new notifications will be…
ElHaix
  • 12,846
  • 27
  • 115
  • 203
10
votes
3 answers

Connecting http request/response model with asynchronous queue

What's a good way to connect the synchronous http request/response model with an asynchronous queue based model? When the user's HTTP request comes it generates a work request that goes onto a queue (beanstalkd in this case). One of the workers…
Parand
  • 102,950
  • 48
  • 151
  • 186