Skip to content
Search

Comet

lastmod 2018-08-17created 2014-05-1210 edits

Due to the nature of the Http protocol, a persistent connection is not possible. So when the client connects, the server sends a response and the connection is closed. In some cases, however, a persistent connection is needed.

comet is also called Reverser Ajax or Ajax Push. Rather than the name of a specific technology, it is a term for push methods over HTTP.

How Comet is implemented

Polling (Ajax)
Sends requests to the server at regular intervals to receive server events. Shortening the request interval lets you receive server events almost in real time. However, it consumes a lot of server resources, so it is hard to use this way in practice.
Long Polling (Comet)
When the client connects to the server, the server keeps the connection open, and when an event occurs it sends it to the client and ends the HTTP transaction. When the client receives the message, it connects to the server again.
Streaming (Comet)
Keeps the connection between client and server open and sends data using HTTP Chunked encoding whenever an event occurs on the server. Because of some limitations, however, Long Polling is usually used instead.

See also

Favorite site

References


  1. Html5-server_send_event.pdf ↩