How does Facebook chat avoid continuous polling of the server?

Posted by Chad Johnson on Stack Overflow See other posts from Stack Overflow or by Chad Johnson
Published on 2010-04-18T20:47:40Z Indexed on 2010/04/18 20:53 UTC
Read the original article Hit count: 375

Filed under:
|
|

I am trying to understand how Facebook's chat feature receives messages without continuously poling the server.

Firebug shows me a single GET XmlHttpRequest continuously sitting there, waiting for a response from the server. After 5 minutes, this never timed out.

How are they preventing timeout?

An AJAX request can just sit there like that indefinitely, waiting for a response?

Can I do this with JSONRequest? I see this at json.org:

JSONRequest is designed to support duplex connections. This permits
applications in which the server can asynchronously initiate
transmissions. This is done by using two simultaneous requests: one
to send and the other to receive. By using the timeout parameter, a
POST request can be left pending until the server determines that it
has timely data to send.

Or is there another way to let an AJAX call just sit there, waiting, besides using JSONRequest?

© Stack Overflow or respective owner

Related posts about JSON

Related posts about AJAX