BOSH

May 27, 2010
by Owen Griffin

I’ve been studying the OneSocialWeb project recently. It’s taken the lead from Google Wave and uses XMPP behind the scenes to handle messages between users.

XMPP over HTTP using BOSH

XMPP is the instant messaging protocol used for Google Talk and Facebook Chat.

BOSH

When browsing the web you are normally issuing lots of separate HTTP requests. Each request is distinct and the server responds when it can. BOSH is required when you want to maintain a connection.

Advantages of BOSH & XMPP

  • Inherent Scalability. XMPP mechanisms for federating servers together.
  • Unreliable connections
  • Firewall happy. BOSH uses the same ports as web browsing, you can find that the default XMPP ports are restricted.
  • Not limited to XMPP. BOSH is often talked about in an XMPP context. 9 times out of 10 BOSH is relaying XMPP traffic. It is possible however to use BOSH to send other types of data.

How does it work?

BOSH clients talk to a Connection Manager. The Connection Manager sits on the HTTP socket and translates requests into XMPP traffic and forwards it onto an XMPP server.

A traditional polling technique will continually poll the server to see if any more data is available. The server will always respond, even if there is no new data. Polling when there is no data available wastes bandwidth, so uses more power, in turn contributing to global warming which will eventually destroy the planet. BOSH is more environmentally friendly.

Instead of continually polling the connection manager a BOSH client will connect and then wait. Only when new data is available will the connection manager respond. Once the data is received the client will then open another connection and continue waiting.

If the client wishes to send data to server whist it has an existing connection then it will open another connection to the connection manager. When the Connection Manager receives a second request it will automatically respond to the first request. There is never more than 2 connections per client to connection manager.

All BOSH requests are wrapped in are wrapped in a element.

For more information consult XEP-0124.

References

XMPP with BOSH

blog comments powered by Disqus