installing punjab xmpp http client interface on ubuntu-server

Written by: daniel

Date March 23, 2009

Punjab allows to connect to an xmpp server like ejabberd, from a client that supports http requests only (for ex. javascript / ajax). It uses some clever parallel connections to handle input and output streams, so there is very little latency when sending and receiving messages.

First, install needed libraries:

apt-get install python python-twisted

then, download the source code from http://code.stanziq.com/cgit/punjab/punjab/

Once unpacked, edit the configuration file punjab.tac.
I changed the port on which punjab is running to 5821, as the default 5280 is already used by ejabberd web admin interface.

Then, install it and run:
python setup.py install
twistd -y punjab.tac

if it works, you should be able to access http://yourdomain.com:5281 (if you changed the port)

The last thing you need to configure is to setup your apache server, so you can use punjab in your sites.
As by default, you cannot open ajax connections to domains and ports different to the ones that your site uses, so we will have to use mod_proxy and mod_rewrite to enable access to punjab.

edit /etc/apache2/httpd.conf and add the following
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>

edit your vhost file and add these lines:
RewriteEngine On
RewriteRule ^/http-bind/ http://yourpunjabserver.com:5281/xmpp-httpbind/ [P]

this means, that everytime you will access yourapplication.com/http-bind/, the request will be transparently proxied to http://yourpunjabserver.com:5281/xmpp-httpbind/

now add the required modules and restart apache:
a2enmod rewrite
a2enmod proxy
a2enmod proxy_http
/etc/init.d/apache2 restart

that’s it! you can now use for example the Strophe xmpp library to create your xmpp applications with javascript.

3 Responses to “installing punjab xmpp http client interface on ubuntu-server”

  1. George Morgan said:

    When you talk about the “vhost file” are you referring to the .htaccess file in the root of portion of your site using XMPP?

  2. daniel said:

    no, I mean when you configure your virtual host in apache you would put it inside “VirtualHost” tag. however, I have not tested it in .htaccess, it might work too.

  3. Problems with punjab in a local network | DevAyd Blog said:

    [...] had to change a little bit the apache proxy module configuration and it worked [...]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>