Monday, November 01, 2010

Strophe client and Openfire XMPP server

It took me 2 hours: I was trying to play a bit with Javascript, long-lived connections/BOSH and xmpp.

I installed Openfire - a java XMPP server, it includes a BOSH servlet, all is very easy to setup. Build from source is also easy and the result works with now extra work. Used the internal database, created user, tested with an XMPP client.

Next I wanted to test from browser - got strophe, changed the examples. The easiest way to set it up is to install it in openfire/resources/spank. The 'bosh' servlet on port 7070 runs with the embedded Jetty, and will serve anything in that dir. This avoids the cross-domain problems. In a prod env you'll probably mix resources from different sources on port 80 - there are some good instructions on how to set apache or nginx, or how to use flash and crossdomain.xml if you really need the bosh server to be on a different domain.

The main trick - the resource name is not /xmpp-bind, not /http-bind as some docs on the web suggest, but /http-bind/. Without the '/' it gets a redirect, and after redirect a GET is done instead of a POST.

No comments: