Openfire, BOSH and StropheJS configuration
I am playing around with some open source Jabber/ XMPP servers and decided to start off with Ignite realtime’s server called Openfire. It’s supposed to have ‘out-of the-box’ BOSH support, so I thought I’d see how easy it would be to get it all working.
Openfire Server set-up
Openfire is a simple download from their website. Installation on my Windows XP laptop was a breeze and the Jabber server was up and running in a few minutes.
The BOSH configuration or rather “HTTP Bind” as Openfire calls it, is also simple to setup from their admin console. Using the defaults you get:-

Openfire
BOSH Client
I chose to try the Strophe Javacript client from http://code.stanziq.com/cgit/strophe/strophejs/snapshot/strophejs-master.zip
Unzip into your webserver folder, I’m using Apache 2.2.8 by the way, and checkout the examples folder where you have a choice of a basic and echobot clients.
If we look at the Javascript code there is a variable BOSH_SERVICE in both examples.
var BOSH_SERVICE = '/xmpp-httpbind';
Openfire uses a different service name, called ‘/http-bind’ and not ‘/xmpp-httpbind’ . So we simply edit and all should now work, right?
var BOSH_SERVICE = '/http-bind';
No, it doesn’t. If we try to browse to http://localhost/http-bind then all we get is an “HTTP 404 Page Not Found” error i.e. there’s nothing there to talk to.
Wait a minute, the Openfire admin console configuration shows that port 7070 is used for this service, so let’s try:-
http://localhost:7070/http-bind
HTTP ERROR: 400
BAD_REQUEST
RequestURI=/http-bind/
Powered by Jetty://
Ah something different, and we have HTTP 400 Error ‘powered by Jetty://’
So this is not working but that’s not entirely suprising as my local Apache server knows nothing about Openfire, or what it’s offering by way of services, nor should it of course.
Hmm, so Openfire must, and indeed does, have its own server that exposes /http-bind on port 7070 hence the ‘Powered by Jetty://’ in the HTTP 400 Error.
Ok, getting somewhere, so how do we get the StropheJS client to connect to port 7070?
There’s nothing we can edit, I tried looking into the source and many other failed attempts at hacking something I decided that I’d have to think, or at least have some coffee, another coffee and lots of Googling and more coffee.
Hidden deep in the Igniterealtimes support forums ( which must be the worst on the planet, sorry guys) was some advice. The fact it took so long to find it was the reason I decided write this blog entry.
All we need to do is to get Apache to forward all requests from the StropheJS client to to http://localhost/http-bind onto to http://localhost:7070/http-bind and that should work.
Ensure the Apache proxy modules are loaded in your httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Then add:-
ProxyRequests Off
ProxyPass /http-bind http://127.0.0.1:7070/http-bind/
ProxyPassReverse /http-bind http://127.0.0.1:7070/http-bind/
And that worked for me! The StropheJS echobot client logged into my Openfire server as soon as I’d restarted Apache and echo’d back anything i sent it.
By the way, I tried the client in Firefox 3.0.6, IE 7, Opera 9.6 and all worked as expected.
However, Safari 3.2.1 logged into Openfire correctly, but the echobot didn’t echo anything. As yet, I don’t know why…..
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=f64a4fd1-cbcc-47de-88e5-9c77f910ddd3)
Paul Blakey said,
Hi, any update on the safari issue?
Adam Fortuna said,
Awesome, exactly the problem I was having. With Ejabberd I was able to just use one apache rule (as follows), but wasn’t working with OpenFire. I added your rules and it worked like a charm.
RewriteRule /http-bind http://localhost:5280/http-bind [P]
Joshua Lim said,
Hi Malcom
Thanks for explaination helped me a lot. I am also writing a Widget now using AIR and Strophe. Will be writing it up and linking to this if you dun mind
Josh
My First (Strophe) Air App « jo-say-yan said,
[...] Open Fire was relatively easy. I basically followed the steps from the documentation and help from Malcom [...]
admin said,
Sorry, I have no update on the Safari issue - been way to busy to get back into playing around with Jabber recently, or indeed to check and approve comments…apologies
Skogsmaskin said,
For me adding:
xmpp.httpbind.client.requests.polling = 0
xmpp.httpbind.client.requests.wait = 10
To the Openfire properties sorted out this issue.
cometta said,
why not just change admin control port 7070 to 80?
Yaron said,
Hello,
It did not work for me.
The httpd.conf did not exist, so I created it and pasted
your lines.
did I miss something?
thanks
Panos Lambrianides said,
I believe there is a simple solution to this problem, namely to change the line in the script to point to the correct port to begin with:
var BOSH_SERVICE = ‘http://localhost:7070/http-bind’
If you look at the strophe.js script this is the url it uses to bind to the BOSH service.
Best.
admin said,
Hi Panos,
Have you actually done this and got it working? If so it looks like they’ve update the strophe.js code to allow changing the port
Add A Comment