Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XMPP BOSH vs COMET

Tags:

comet

xmpp

I want to write a real-time chat application and in need to decide which technologies to use.

What are the differences between these technologies and which do you prefer and why?

WebSockets in not an option, since its not ready to fight in wild

Thanks

like image 840
Ahmet Recep Navruz Avatar asked Sep 06 '11 23:09

Ahmet Recep Navruz


People also ask

What is BOSH in XMPP?

The BOSH TechniqueWhen the client sends a request, the connection manager does not immediately send a response; instead it holds the request open until it has data to actually send to the client (or an agreed-to length of inactivity has elapsed).

What is Bosh connection?

Bidirectional-streams Over Synchronous HTTP (BOSH) is a transport protocol that creates bi-directional TCP connectivity between client and server. It achieves this by utilizing multiple synchronous HTTP request/response pairs without requiring the use for chunking.


1 Answers

You should read the question "Why isn't BOSH more popular especially as an alternative to WebSockets and Long-Polling". kanaka gives a fantastic answer and I'm sure it'll address the concerns you have about WebSockets. WebSocket are absolutely "ready to fight in the wild".

BOSH and Comet, in my opinion, are the same thing. BOSH stands for "Bidirectional-streams Over Synchronous HTTP" and although the BOSH specification states:

BOSH, the technology defined in this specification, essentially provides a "drop-in" alternative to a long-lived, bidirectional TCP connection. It is a mature, full-featured technology that has been widely implemented and deployed since 2004. To our knowledge it was the first of many similar technologies, which now include the Comet methodology formalized in the Bayeux Protocol as well as The Web Socket Protocol and Reverse HTTP.

I know for a fact that Comet servers have been around since at least 2001, since I worked for a company (Caplin Systems) who had, and still have, a Comet server.

The reason I say that they are the same thing, at a fundamental level, is that they both originally (see below) relied upon two HTTP connections. The first is a back channel which is either a long-held HTTP Streaming connection or use for HTTP Long-Polling. The second connection is short-lived and used for sending commands such as subscription requests. These two connections allowed for the bi-directional communication to be simulated.

So, at a fundamental level BOSH and Comet use the same mechanisms for server to client and client to server communication (client being a web browser or other supported web client). Where BOSH differs is it offers added detail within it's protocol and was developed with XMPP in mind. Any Comet server could be developed to adhere to the standards defined in the BOSH spec.

All this said, Comet and BOSH servers will undoubtedly offer alternative transport mechanisms. These will include HTTP Streaming, HTTP Long-Polling, standard HTTP-Polling and WebSockets.

So, if you want the detail that is provided by BOSH and XMPP then you probably want to consider a technology stack built with BOSH and XMPP in mind. If you want to send simple messages, without that added payload inherent in BOSH and XMPP, or if you want to build your own 'added value' to your own protocol then something labelled as a Comet server is probably a better solution.

If you choose to use an existing technology stack, rather than develop a solution from the ground up, then it's highly likely that the solution will use WebSockets were possible since they offer a standardised and efficient bi-directional communications mechanism.

I've made my first attempt at a realtime web technology stack diagram which you can see below. Hopefully it helps a bit:

Realtime Web Technology Stack

You can find a list of realtime technologies here.

like image 72
leggetter Avatar answered Oct 05 '22 09:10

leggetter