Has anyone written an open source XMPP library that uses WebSockets and is meant to be run by a browser?
You can check if a WebSocket is disconnected by doing either of the following: Specifying a function to the WebSocket. onclose event handler property, or; Using addEventListener to listen to the close event.
For now, I think there are plenty of applications already using Websocket. And there are many frameworks developed for Websockets in almost all the programming languages. They are very matured as well. Only caveat developers may think of Websocket is that, the fact that it's not HTTP.
WebSocket provides a client-server computer communication protocol, whereas WebRTC offers a peer-to-peer protocol and communication capabilities for browsers and mobile apps. While WebSocket works only over TCP, WebRTC is primarily used over UDP (although it can work over TCP as well).
However, it's important to note that if the user wishes to use WebSockets, then the downgrading handler must be used, as traditional gRPC servers do not support WebSockets.
There are multiple solutions (none of them are perfect)
They already support it. It's open source, but they have some sort of dual license, so better to check whether you can use for your project or not.
APE is a Comet framework, but they recently started supporting Websockets. At their website("APE as proxy" section), they say it can run js.io libraries which includes xmpp.js, so combining them may work.
It is a java based framework similar to APE which provides one stop shop Comet solution, and they seem to support both XMPP and WebSockets
Strophe does XMPP over BOSH(Bidirectional-streams Over Synchronous HTTP), but there is a discussion about supporting WebSockets, too.
Jack Moffitt (the core developer and the author of the book mentioned above) seems interested in WebSockets, but we need to provide more strong reasoning about why they need to support WebSocket over BOSH. If you have good answers, please join the tread.
I just tried their xmpp,bosh,strophe echobot example, which worked nicely. You might also want to try it to see if it fits your requirement or not.
For #2 and #3, they say that they both support xmpp and websockets, but not sure if they work together.
What kind of application you are thinking about using XMPP & WebSockets for?
The below are suggestions for alternatives.
I got most of the information above when I wrote this blog post. If you check the comment section time to time, I will post update once I find other solutions.
We don't yet have a standard for XMPP over WebSockets that the servers can implement, which will be required before the client side can be tackled adequately.
The first step is to finish WebSocket standardization. It looks like this may happen in an IETF HyBi working group, which at the time of writing has not yet been approved by the IESG. There was a HyBi Birds-of-a-Feather (BoF) at the Hiroshima IETF meeting a couple of weeks ago (see the meeting materials), which went pretty well.
After WebSockets has a stable reference, and seems to be settling down, the XSF will create a XEP that binds XMPP to WebSockets, presumably with a stanza per WebSocket frame.
Edit: Jack Moffitt has written an IETF Internet-Draft with a first pass at a protocol that can be used. WARNING. This is still likely to change drastically. Only implement it if you're willing to rip it out completely later. WARNING.
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