JWChat for Drupal

License: GNU General Public License
Version: 0.1 Beta
Requires: ejabberd 2, Drupal 6
Description: Integrates JWChat in an Drupal installation and provides Instant Messaging via Jabber.

JWChat in Drupal
JWChat in Drupal Zoom

» View Demo as a Elgg plugin (same functionality)


This page describes how to provide instant messaging via a discrete jabber server in the framework Drupal. As frontend I used a modified version of the web based JWChat. The backend communicates with the jabber server at database level and takes care about correct registrations and buddy lists.

Please Note

  • Currently there is only ejabberd 2 support.
  • The browser support of JWChat should be simmilar with the browser support of this plugin.
  • This plugin needs access to the database used by the jabberserver.
  • Multi user chats (muc) are possible. However, the admins have to be hardcorded in the config file of ejabberd.


  • Set up ejabberd with MySQL native driver, described here. Adjust the additional modules mod_last, mod_offline, mod_roster and mod_vcard as well (like he describes at the end). If your drupal is using another DBMS you have to set up ejabberd to use that DBMS. Note: Here you can download debian packages for erlang mysql support.
  • Make sure that either HTTP-Polling or HTTP-Binding is activated in the ejabberd config. For help please consult Google or the ejabberd doc.
  • Configure your webserver. How to do that is described in the README of JWChat (quote):
    • Setup your web server so that it redirects some local address like http://jabber.example.com/http-poll/ to some service that either implements HTTP Polling or HTTP Binding.

      Here is an example that should work with a default ejabberd installation on the same host:

      <VirtualHost *>
      ServerName jabber.example.com
      # (...)
      AddDefaultCharset UTF-8
      RewriteEngine on
      RewriteRule http-poll/ [P]


      Note 1: You need to enable mod_rewrite and mod_proxy at your apache configuration. Apache2 users also need to enable the protocol specific proxy module mod_proxy_http.

      Note 2: With JabberHTTPBind you don't need to do this sort of address rewriting if you're serving JWChat's files from within your servlet container directly or you're using some technique like mod_jk to mount a remote servlet engine directory transparently into your apache's domain of served addresses.

    • Restart your web server.

    • Test if this redirect works. Following the example above point your browser to http://jabber.example.com/http-poll/. You should see the same response as if you you're pointing it to http://jabber.example.com:5280/http-poll/.

    I had to modify the example using the following lines.

    <VirtualHost *>
    ProxyPass /http-bind/
    ProxyPassReverse /http-bind/
    # further more stuff..

    Replace with the server address of your ejabberd.

  • Now the plugin comes into play. Download and extract it and copy the jabber folder into the module directory of your drupal installation.
  • Add the database connection to the jabber server to your settings.php
    To do so you have to declare $db_url as an array. For example if your
    current settings.php looks like this:

    $db_url = 'mysql://username:password@localhost/databasename';

    You have to change it to this:

    $db_url['default'] = 'mysql://username:password@localhost/databasename';
    $db_url['jabber'] = 'mysql://jabberuser:jabberpass@jabber.example.com/jabberdb';

    Note that the jabber server and the drupal installation have to use the same DBMS.

  • Enable this module by navigating to Administer > Site building > Modules.
  • Go to Administer > User Management > Access control, and give the permission access jabber to the roles you like (probably authenticated users).
  • Configure the module by going to Administer > Site configuration > Jabber server parameters. Set the options depending on your specific jabber server setup. My test configuration looks like this. Note: In most instances you cannot run the jabberserver as localhost, because your users won't be able to connect to it.
  • If all looks fine you should remove the module mod_register from the ejabberd configuration file. After that only the plugin is able to change passwords or registrate users.
  • Thats it! Surely its a bit nasty to come to this point, but at the end all efforts pay off :)