Setting Up Openfire Service
Along with chat client - Converse.js
Openfire (previously known as Wildfire, and Jive Messenger) is an instant messaging (IM) and groupchat server that uses XMPP server written in Java. [1]
I needed a chat server and a chat client for one of my web applications. So, I started looking out for some existing solutions and found Openfire as one of the best option for using as a chat server (I didn’t know at that time how much difficulty I was gonna face :p) and Converse.js as a chat client.
I am using Fedora 17 as my OS, so I chose the Linux version of Openfire. You should choose the proper version accordingly, here is the download link:
Openfire 3.9.3: http://www.igniterealtime.org/downloads/
Openfire installation and initial steps
After downloading Openfire you can follow the installation guide provided at [2], its simple ;)
To start, stop, restart and check status of the Openfire service you can use the following commands in Fedora-
$ sudo service openfire start
$ sudo service openfire stop
$ sudo service openfire restart
$ sudo service openfire status
(Since I am using Fedora, so, I would mostly talk about Openfire in context of Fedora)
Now, if you are done with the above steps, you can go and visit 127.0.0.1:9090 to start with the next steps involved in setup of Openfire. This is easy and simple with one important step involved about choosing the database, you will have two options here as shown below:

You can choose either the Standard Database or the Embedded Database option provided by Openfire to store user information. Embedded Database is good for chat servers with small number of users but if you have an application which involves a large number of users, as in my case, you should probably choose the Standard Database option. If you chose the option of Standard Database, you will see an option of choosing the type of database on the next screen, as shown here:

I chose MySQL but there are a whole lot of other database options, you can choose any. In the Database URL field replace [host-name] with your database server URL, in my case its localhost, as the mysqld service is running on the same server as Openfire, and replace [database-name] with your custom database. In the username and password field fill in your database username and password through which you want to make the database connection.
Caution: If you have database running on a different server make sure port 3306 used by MySQL is not blocked for incoming connection by firewall, otherwise you would be scratching your head and wondering why it is not working.
After completing the above steps and a couple of steps more, involving administrator settings, you are done setting up Openfire. Now, you can login to the admin panel by visiting 127.0.0.1:9090. You can create a couple of new users under the tab Users/Group, we will need them during testing.
Re-running the Openfire setup
In case, you need to re-run the whole setup again, you can do so by changing the setup parameter to false which you can find in openfire.xml configuration file under conf folder in Openfire installation directrory, and restarting the openfire service. You can now visit 127.0.0.1:9090 to start the setup all over again.
...
<setup>false</setup>
...
Testing Openfire with Converse.js as the chat-client
You can find a download link to Converse.js below:
Converse.js 0.8.4: https://conversejs.org/
Here is a quickstart [3] guide to get a demo of Converse.js up and running. Below is the configuration settings you will be required to include on the demo page:
require(['converse'], function (converse) {
converse.initialize({
auto_list_rooms: false,
auto_subscribe: false,
bosh_service_url: 'https://bind.conversejs.org', // Please use this connection manager only for testing purposes
hide_muc_server: false,
i18n: locales.en, // Refer to ./locale/locales.js to see which locales are supported
prebind: false,
show_controlbox_by_default: true,
roster_groups: true
});
});In the above configuration, you should change value of the bosh_service_url parameter to ‘http://[server-url]:7070/http-bind/’, where [server-url] is the URL of the server on which Openfire service is running, in my case it is localhost.
Now, run the demo page of Converse.js to test the chat-server. Try logging in using the credentials of one of the users you created from the Openfire admin console. If you are successfully logged in, then celebrate ☺ and if not then don’t worry, I will help you out ☺.
Debugging:
- First, go to your firewall settings and check if the ports required for client connection are open. Ports you need to check are 5222, 5229, 7070 and 7443, if they are not open make an exception for them and open them up. Now, try again logging in through the Converse.js demo page. If you are successful in logging in then skip the next point.
- If still you could not login, then it may be possible that the size of the thread pool used to handle your inbound BOSH requests has been set to zero. By default this value should be 16, but this value may be overridden by either of two Openfire system properties:
xmpp.httpbind.worker.threads
xmpp.client.processing.threads
If either of these two properties have been set to zero or negative value, you should simply delete the invalid key/value pair(s) using the “System Properties” page on the admin console and then restart Openfire. Alternatively, you can set there value to 16, again using “System Properties” page.

If you have followed the above steps correctly, then I hope you must have been able to login on the Converse.js demo page.
Authentication Using Custom User Database
This is useful when your users already have accounts in an external system and you do not wish to duplicate those accounts in Openfire.
You can follow the Custom Database Integration Guide provided at [4]
But, this is not complete you need to do something more to get it done, which is provided here [5]
Making a user admin
You’ll most likely want to change which usernames are authorized to login to the admin console. By default, only the user with username “admin” is allowed to login. You can add the following lines, in openfire.xml which can be found in the conf folder of the Openfire installation directory:
<jive>
...
<admin>
...
<authorizedUsernames>joe, jane</authorizedUsernames>
</admin>
...
</jive>
Hufff … the setup of Openfire and integration of custom user database is complete now ☺.
References:
[1] http://en.wikipedia.org/wiki/Openfire
[2]http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/install-guide.html
[3] https://conversejs.org/docs/html/index.html#quickstart-to-get-a-demo-up-and-running
[4]http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/db-integration-guide.html
[5] http://stackoverflow.com/questions/10385809/openfire-external-user-auth