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
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).
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.
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:
You can find a list of realtime technologies here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With