Understanding the Atmosphere Protocol - Atmosphere/atmosphere GitHub Wiki

The Atmosphere Framework uses a really simple communication protocol between its supported client and the core server component. By default, atmosphere.js attach, to the request URI, a list of query string that are used by the core server component. It can also set those value as requests headers if required. If you are planning to write an Atmosphere enabled client, the mandatory keys/values are:

  • X-Atmosphere-Framework = version The lowest Atmosphere's version supported
  • X-Atmosphere-Transport: sse|websocket|long-polling|streaming|ajax|jsonp The transport used for that connection.
  • X-Atmosphere-tracking-id: value Originally set to 0, this value will be set by the server in order to uniquely track the client and sent back as a response's header of the same name.
  • _timeStamp A unique value starting with _ . This is required to prevent browsers/proxy from caching request.
  • X-atmo-protocol Set to true so the server will send back the X-Atmosphere-tracking-id and X-Cache-Date on the first request so all transactions occuring after have the proper value.

For example, a request may looks like

T 127.0.0.1:57618 -> 127.0.0.1:8080 [AP]
GET /chat?X-Atmosphere-tracking-id=e24de98c-6624-c552-5572-6edbffd270e3&
X-Atmosphere-Framework=1.0&X-Atmosphere-Transport=long-polling&X-Cache-Date=134183423411
&_=1341834834155 HTTP/1.1.
Host: 127.0.0.1:8080.
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101 Firefox/13.0.
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8.
Accept-Language: en-us,en;q=0.5.
Accept-Encoding: gzip, deflate.
Connection: keep-alive.
Referer: http://127.0.0.1:8080/.

When the client is closing the connection, the following message will be sent:

T 127.0.0.1:54684 -> 127.0.0.1:8080 [AP]
GET /chat?X-Atmosphere-Transport=close&X-Atmosphere-tracking-id=b87815c9-3f3d-4fef-8f44-1e85c9156e43&_=1373382436869 HTTP/1.1.
Host: 127.0.0.1:8080.
Connection: keep-alive.
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36.
Content-Type: application/json.
Accept: */*.
Referer: http://127.0.0.1:8080/.
Accept-Encoding: gzip,deflate,sdch.
Accept-Language: en-US,en;q=0.8.
Cookie: nikio.guid=2e87c963-0668-4e2f-8e91-63c2eb759558; hudson_auto_refresh=true.
  • X-Atmosphere-Transport: close
  • X-Atmosphere-tracking-id: the value received first.