Has anyone written an open source XMPP library that uses WebSockets and is meant to be run by a browser?
问题:
回答1:
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.
回答2:
There are multiple solutions (none of them are perfect)
1. Use Kaazing.
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.
- XMPP JavaScript How-To
2. Combine js.io and APE(Ajax Push Engine)
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.
- How to write an application with APE
3. Use Caucho
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
- Caucho Resin
- Caucho Websocket example with Resin
4. Ask Strophe team to support WebSocket.
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.
- If you want the presence, chat, chat room equivalent functionality, you could make Wave Gadget or Robot, then expose to outside using Wave Embed API(dead link, kept for historic purposes). Wave is actually built on top of XMPP.
- If you are simply looking for very low latency messaging capability, you could try AMQP.
- If you are looking for much simpler message streaming, you can just pipe in/out unix file as I demonstrated here.
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.
回答3:
There's a book coming soon that covers this topic...
Professional XMPP with JavaScript and jQuery alt text http://ecx.images-amazon.com/images/I/51B7VAHw8OL._SL500_AA240_.jpg
But I'm assuming you don't want to wait for the book. So watch the Jack Moffitt's presentation from JSConf. I watched it this morning. (Jack Moffitt is the author of the book linked to above.)
The library involved (JavaScript and C implementations) is Strophe.
This is a very fruitful area of exploration, but very raw. We'll see more soon. WebSockets come with HTML5, is that right?
回答4:
JSJaC implements XMPP Over Websockets. It's known to work with several backend implementations:
- node-xmpp-bosh - supports RFC6455 and works with no problems since 0.6.1, it also transparently uses STARTTLS if necessary
- wxg - supports RFC6455 and works with no problems, but cannot connect to servers requiring STARTTLS (original wxg has some issues, that were fixed by Gordin).
- ejabberd-websockets - does not support RFC6455 hence it does not work, adapting it to support RFC6455 should be quite easy for anyone knowing Erlang (some work in progress can be found on github)
- Openfire - unofficial plugin is available, but it lacks support for RFC6455 hence it does not work
- Apache Vysper - does not support RFC6455 hence does not work
- Tigase - no known work on WebSocket support
- MongooseIM - a fork of ejabberd with support for XMPP over Websockets.
回答5:
I'm not sure JS on browser side can handle websocket protocol alone as it mostly rely on browser API. Few browser support websocket yet: Chrome, Safari5, maybe Firefox4. There are many workarounds based on flash/as3 (then your js communicates with flash code) the the main limitation is that flash does not support secure connection (too bad).
BWT, you can check this websocket implem they provide opensource Java websocket client lib and seems to deal with xmpp stuff and if you browse the repositories you might find basic as3 websocket implementation.
回答6:
I am not sure why you are asking specifically for a WebSocket solution because the XMPP servers would have to support this first.
However there are several XMPP JavaScript libraries available (as far as I see they all use the BOSH method):
- Dojo toolkit has an XMPP extension library
- JS.io
- JSJac
- Strophe.js
- xmpp4js
- Z-XMPP
These examples were taken from the XMPP Website which lists open source implementations of the XMPP protocol.