Overview
Under the IM Tab in Elastix, you will find a product called Openfire. In simple terms, Openfire is a very popular Messaging (Chat) and Presence Server, that uses the Jabber/XMPP protocol. You will find that the actual protocol is correctly referred to as XMPP (Extensible Messaging & Presence Protocol).
You might be thinking, what do I want with a Openfire server, what use do I have for it. You actually may be using products that already use the Jabber/XMPP protocol right now such as Google Talk or similar. Jabber/XMPP is not just one product. It is the base for a range of products that use XMPP and as it says, it is Extensible, which means that its capabilities can be increased, especially with Plugins. One of those Plugins is the Asterisk IM (Instant Messaging) which joins the Openfire server to the Asterisk Server and allows them to talk.
Naturally with any server product, you need a client before some functionality is realized. There are literally heaps of clients that support the XMPP protocol, but in particular, the one developed by the same developers that designed Openfire, is called Spark. It doesn’t mean that it is the best and will suit everyone, but it is able to showcase some of the capabilities of the Openfire server.
So what can we do with Openfire and the Asterisk IM Plug-in and a suitable desktop client such as SPARK?
○ Instant Messaging between people on your Network, even Networks joined by a Wide Area Network.
○ Instant messaging to external people, using the Openfire Gateway plug-in which allows connection to other messaging systems such as (AIM, ICQ, MSN, Yahoo, etc).
○ Presence monitoring. The system can monitor whether you are away from the keyboard, offline, on the phone. This makes it easier for people to see whether to call you or chat to you (if you are on the phone and it is urgent that they reach you). Furthermore, with another additional Plug-in, you can publish this presence information to a Web Page.
On paper it does not seem like a lot, but there are many more applications and Plug-ins that work with Openfire, and it is up to you to decide whether they are suitable to you and make it the product that you want. Even with those items alone, once implemented and integrated into a Business, it makes a huge difference in the efficiency of a business.
Just one more thing, why would you use MySQL for Openfire, instead of the simpler embedded database (HSQLDB). The reasons are simple.
- MYSQL is already installed on Elastix systems
- MYSQL Tools are far more numerous and available
- MYSQL is far more scalable
- Using the embedded database, requires manual changes to the Asterisk-IM plugin, which a lot of people have trouble with as there is a small bug in the SQL script.
So let’s get started.
Already Commenced an Openfire Configuration and want to restart again?
Just in case you have already commenced an Openfire install, especially if you have selected the HSQLDB (embedded database) option, and want to change to a MYSQL database, you can basically restart your setup by performing the following steps via SSH or the Linux console
cd /opt/openfire/conf
nano openfire.xml (or what ever your favourite editor is) - in otherwords we are editing openfire.xml
change the following XML tag from
<setup>true</setup>
to
<setup>false</setup>
Reboot your Elastix system and then goto the Openfire Tab and it should commence the Openfire setup again. At this point you need to follow the tutorial
Naturally if you do this step, any users, setups, groups will be lost, and will need to be setup again, so be warned!!!
OPENFIRE INSTALLATION
Before we start the installation, we are going to setup a database for Openfire to use.
You need access to the Linux console directly or via SSH (Putty etc) if you are performing this from a workstation.
First we are going to create a database called openfire in the default MYSQL Database in Elastix
You will find many examples on the internet do not complicate things with user login and password. It is generally assumed that you know the drill. In our case, by not specifying the username, it uses root, and we add the -p option to force it to ask the password. Naturally the lines that start with # are only to show that the commands are typed at the console. You do not include the # as part of the command
#mysqladmin -p create openfire
It will ask for a password which is
eLaStIx.2oo7
(note this is the default root password for mysql as per Elastix Install)
Next we need to build the schema (or tables for a simplistic concept).
#cd /opt/openfire/resources/database
#cat openfire_mysql.sql | mysql -p openfire;
Thats it. We have now constructed a database and populated it with the empty fields. We can now commence the Openfire install proper.
Login in to your Elastix Web GUI and click on the IM Tab and you should be in the following screen.
Click on the CLICK HERE hyperlink and the following screen will appear after a short wait (it is setting up the application for use).
Select the language that you want to use and click on Continue and the next screen will appear
This screen lets you setup your domain name for your system and must match the domain name of your Elastix System. If you haven’t setup a domain name correctly on your Elastix system, then drop out of this installation program and do it now.
In the Elastix Without Tears guide, you will find a Brief Guide to Networking with Elastix which explains in reasonable detail how to setup Networking.
If you change the way your system is setup in terms of domain, at a later date, it will break your Openfire application, and while it is possible to recover from this issue, it could take you hours.
With the ports, leave them as they are. They are the default ports.
Click on Continue and the next screen will appear
In this screen, you have two choices. The first one is a standard Database connection, and the other is embedded. Originally this tutorial was done with the Embedded Database, but considering the bug fix that was required to get things working, as well a few occasions during these changes that Openfire collapsed leaving a unrecoverable half install, it was decided that it would be better off using the MYSQL database which is already installed in Elastix for Freepbx, Asterisk.
So the recommendation is select the Standard Database connection, and click on Continue.
Now the following screen will appear
So you set the following fields
Database Driver Presets: Drop the box down and select MYSQL
JDBC Driver Class: This will populate when you selected MYSQL. It does not get changed.
Database URL: jdbc:mysql://yourhostnameanddomain:3306/openfire (replace the yourhostnameanddomain with your Elastix Hostname and domain. The example shows
jdbc:mysql://elastix.netintegrity.local:3306/openfire , with elastix.netintegrity.local being our lab machine host name.
Username: root (this is the username we are connecting to the MYSQL Database)
Password: eLaStIx.2oo7 (this is the password we are using to connect to the MYSQL Database)
Press Continue, and if everything is correct, you will proceed to the next page.
This screen allows you to choose where to store your users and groups. For most you will select default, using the database to store your users and groups which is fine for most setups.
The other option, is to use the LDAP protocol using and LDAP compliant system to store the users and groups such as Microsoft Active Directory, or another Linux System, where the users, passwords and groups are already implemented. Unless you are very familiar with LDAP, leave it at default.
Click on Continue
Enter your normal accessible email address as the admin email address. Now the confusing part is that it asks for a password and password confirmation. It has nothing to do with the email address. It is the admin password that you will use for the Openfire system. For a new user it would have made it easier to understand if they had separated it (still keeping it on the same page as it is to do with the Admin Account), and gave a separate explanation.
Make sure that you use a password that you know well, or at least write it down. You lose it, and it is not a simple measure to recover it.
Click on continue
![setupcomplete.jpg setupcomplete.jpg](http://www.elastixconnection.com/images/stories/tutorials/openfire/setupcomplete.jpg)
That’s the first part. You now have functional Openfire Server, which you can login in to and setup further.
Click on LOGIN TO THE ADMIN CONSOLE and you will get the following screen which will allow you to login.
Login with the username admin and the password is the one that you selected back at the admin account. Remember, that was one which you were told to write it down and don’t lose it.
The next screen will confirm that you indeed have a functional Openfire Server running.
Don’t panic, there is a lot on this screen, but we will take you through the few basics that you need.
Don’t upgrade Openfire yourself; these updates will come from Elastix. Remember that they have integrated it into the Elastix system, and there may be minor tweaks to allow this to happen. These minor tweaks however, may be the difference between your Openfire Server working or not working.
ASTERISK INSTANT MESSENGER PLUGIN INSTALLATION
We are now going to add some Plugins into the system to make it functional. So in the Openfire Console, click on the Plugins Tab, and the following screen will come up
This screen shows that there is only one Plugin installed by default. We are now going to quickly add a few more.
So click on Available Plugins from the side menu and the following screen will appear.
What you see in this list is a list of Plug-ins that have been registered with Openfire. You may find this list increase, allowing you to add another new plug-in that might be suitable for your system. You can click on the UPDATE NOW hyperlink, if you want to confirm if there are any more available.
You can also manually upload Plugins, e.g. ones that are not part of the registered Plugins, but we don’t require that at this stage.
Now to install the Registered Plugins, all we need to do is click on he Green + Plus sign, under the heading install. So the first one we are going to install is the Asterisk-IM-Openfire-Plugin, so click the Green Plus Sign on that line and the following screen will appear.
You will note that the Green Plus sign turns into a little “Loading Timer”, and may take a short while to install. Once completed, it will automatically remove itself from the screen, as it has now ended up in the Plugins
So the same for, IM gateway, Presence Service and SIP Phone Plugin. If you now click on the Plugins on the left menu, you will see the Plugins that you have installed.
You can also delete the Plugins from this screen or restart them if you need to. You will also notice that we now have a new tab at the top called ASTERISK-IM, which is the result of installing the ASTERISK-IM plugin.
Click on that ASTERISK-IM Tab and the following screen will appear
.
Click on the Asterisk-IM Radio Button , click on the Asterisk Queue Presence Radio Button and add the word default to Asterisk Context input Box similar to the following screen
Once you have done this, then click SAVE
Now a Add Server hyperlink should appear, click on it and the following Screen will appear
Add the following items into the input boxes
Server Name: elastix.yourdomain.local (Same as your Elastix box domain)
Server Address: 127.0.0.1 (Always this for this install)
Port: 5038 (This is the Asterisk AMI Port number)
Username: admin (this is a user in manager.conf by default)
Password: elastix456 (this is the default password)
So you screen when filled in, should look this
Click on Create Server and if everything is successful, you should see the following screen
Take special note of the green dot next to the name of our Elastix box. If it is green then the Openfire server has a working connection to our Elastix Server. If the server address is missing altogether, then you either did not reboot the Elastix Server (which meant the bug fixes are not applied), or you have not edited the file correctly.
If the green dot is actually grey, then you have correctly edited the file, but it appears that for some reason you have not correctly connected to the Elastix Server. This may be the result of the user and password not being set correctly for the Asterisk Management Interface. The ones that we have provided in this chapter, are ones that are setup by default by Elastix. If you have changed manager.conf under /etc/asterisk, you will need to correct the login and password to suit.
So if you have the green dot, you now have a working Openfire Server connected to your Elastix Server.
OPENFIRE USER SETUP
All we need to do now is add users and install the client on the desktops.
Click on users and groups tab at the top and the following screen will appear
Only the admin user will appear. We now need to create users for your system. Click on create new user on your system. And the following screen will appear.
Fill in the details for each user you want to connect to Openfire. Keep the usernames in lower case (makes it easier), fill in their proper name, their current email address, and provide them with a password. This password does not have to match anything, it will be used by the client that resides on their desktop to connect to the Openfire server.
So you should have a screen like so:
Click on CREATE USER (or Create and Create Another if you want to keep adding more).
After you have done this, you should see the screen (we have only done one user) like this
We have now setup one user on the system. For the system to recognise when we are on the phone, we need to map the user to an extension
OPENFIRE USER/PHONE MAPPING
We do this by clicking again on the Asterisk-IM Plugin Tab and then clicking on Phone Mappings on the left menu. You should see a screen like so:
We are now going to setup a phone mapping for the user that we just setup under Users and Groups.
Username is the username you setup, in this case it was bob (remember I said to setup in lowercase, it just makes it easier, as the system will not recognise if you use an uppercase char, it sees it has a different login).
The device is the actual phone, and you should be able to drop down the box and it will show extensions that you have in your Elastix System. If it doesn’t show, then you can enter it manually (e.g. for our one user we would add SIP/301). Then add the extension number which is the same, without the SIP/, so we would enter 301 in here, and then a caller ID. I normally enter 301 in here as well. You can click on the primary field as well if you like, but it is not crucial. This does have a purpose, but it is for more complex systems which are beyond the scope of this document.
After you have pressed the add button, you should see the following user setup
You have now successfully mapped a user and phone together.
Now to install a client. As mentioned the SPARK Client from the same people that developed Openfire, is a good starting point. You can always change the client later, whenever you want, and by then, you will know what you are looking for in a client.
CLIENT INSTALLATION
So for now we are going to use SPARK. You can download it from http://www.igniterealtime.org/projects/spark/index.jsp
Install it as per default install instructions. And you should end up with the following screen
Now we enter in the details that we setup as a user
Username: bob (remember the lower case user name)
Password: Whatever (the password that you setup for that user)
Server: The IP address of your server (not the 127.0.0.1) address - in our case 172.22.22.100
Click on Save Password and click on Auto Login.
And then click on Login. If all is successful, you will end up with the following screen
Our client has now successfully connected to the Openfire server. If we had more users installed, we would see the users listed, showing their presence status, whether they are offline, on the phone, away from keyboard etc.
Just one note. In the mode that we have show, you will have to accept users and they you, before they will show up on your list (very much like ICQ and similar). If this is not what you want, and you want all the people that are on your local Network to be immediately available to each SPARK user, then you can set them into Groups (a subject we did not broach). If you go back to Openfire Users and Groups Tab, create a Group Name and add the selected users to the Group and they will be immediately available to communicate with if they are a member of that group.
There are many more features, and functions within Openfire. It deserves a book all by itself, which again is not the purpose of this document. We hopefully have provided enough to get you started, so that you can explore Elastix and the integrated Openfire server.
Tutorial Changelog
29 May 2009 - Submitted by Bob - Added paragraph for users who wanted to reset their current Openfire configuration.
12 Dec 2008 - Submitted by Bob - corrected directory to read database schema from.changed # cd /opt/openfire/resources to # cd /opt/openfire/resources/database