mark.bockenstedt.net header image
Twitter
Gaming Linux Mac Software Tech
mu Updates
Web
Musings Rants & Raves Rumor Sports Weather
Video Reviews

Laconica, XMPP, SMS, Oh My!

September 22nd, 2008 · 2 Comments

Last Monday’s post was a bunch of directions on how to install Laconica on your own server. What the directions failed to mention was how to set up the good stuff – XMPP, SMS, and posting via email. Today I’ll go over how to get XMPP and SMS running.

SMS

Populate carriers table

If you look in the db folder, you’ll find a file called carrier.sql. If you run that against the laconica database you created for the install, all the providers in the file (58 in all) will be available to select in the SMS tab of your instance. I actually reduce the number to 16 because most of them are international services.

How SMS works is the Laconica server will fire off an email to your carrier’s gateway, which then should be delivered as an SMS. Not all carriers play well with this (I’m looking at you, US Cellular) so your mileage may vary in terms of results. I’ve already got a confirmation that AT&T works.

If carriers are missing from the table and you know the carrier’s gateway, it’s really easy to add them to the options. Simply create a new record in the sms_carrier table and fill in the name and email pattern.

Try it out

Head to the Settings -> SMS tab of your instance, enter your phone number, select your carrier, and hit the Add button. You should receive an SMS with a confirmation code, which you’ll have to enter in the new box that appears. Once you do that, your phone should be prime for receiving SMS to your phone.

SMS is one-way

What I mean by that is you can only receive notifications through SMS – you can’t post updates to the service (yet). This simplifies matters because admins won’t have to worry about setting up all the SMS inbound boxes and all that. For now, this will work.

XMPP

This is where things get ugly. If you’ve already got a Jabber/XMPP server, you’re golden. If not… get one.

Configuration

If you already have an XMPP server, you can do this now. Otherwise, install one and come back to this.

Head back to the trusty config.php file and scroll down to the XMPP section and you’ll find a plethora of options regarding XMPP. If you have a server, fill in the appropriate values and you should be good to go.

Choosing a Server

You can probably use whatever server you want to for this, provided it does the job. I chose to use Openfire, a bloated Java server. Frankly, I had no reasons behind the choice other than it worked after some configuration. All directions henceforth will be specific to Openfire.

Installation

Before I jump into the juicy details, bookmark the Openfire Documentation page. It will become your best friend.

sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
cd /opt
wget http://www.igniterealtime.org/downloadServlet?filename=openfire/openfire_3_6_0a.tar.gz
tar -xzvf downloadServlet?filename=openfire/openfire_3_6_0a.tar.gz

The next step is to set up the database. I’m going to assume you’re using MySQL, but you can use any of the following: DB2, HSQLDB, MySQL, Oracle, PostgreSQL, SQLServer, or SyBase. I’ll also assume you’ve created a database to hold Openfire info (database named openfire).

cd /opt/openfire/resources/database
mysql -u [db_user] -p [db_pass] openfire < openfire_mysql.sql

Start Server

Now it’s time to kick this bad boy off and see if it works:

cd /opt/openfire
./bin/openfire start

If it complains of not being able to find a JVM, try doing this:

sudo update-alternatives --config java

and select a different JVM. The JVM installed from above is at /usr/lib/jvm/java-6-sun/jre/bin/java so that’s what I selected. I have no idea if that impacts the rest of the system at all.
OK, so now your server should be running. Time to set it up.

Setup

If you were able to run the server without incident, point your browser to port 9090 on the server you installed Openfire on. Follow the on-screen prompts. I screwed the pooch and didn’t take screenshots of the process.

Create an update user

Go into the Users/Groups page in your Openfire Admin Console (OAC) and create a new user and give it a password. I named my user update, but the name is arbitrary.

Update the Laconica config

If you’re just installing an XMPP server, you need to make sure to tell Laconica about your new Openfire user. Here’s what my XMPP config looks like:

$config['xmpp']['enabled'] = true;
$config['xmpp']['host'] = 'bockenstedt.net';
$config['xmpp']['server'] = 'bockenstedt.net';
$config['xmpp']['port'] = 5222;
$config['xmpp']['user'] = 'update';
$config['xmpp']['encryption'] = false;
$config['xmpp']['resource'] = 'xmpphp';
$config['xmpp']['password'] = '';
$config['xmpp']['public'][] = 'imbuddy@bockenstedt.net';

Simply change the above fields where appropriate and Laconica should be informed about your XMPP buddy. I dont’ know what the last line is for, so if anyone can clue me in, please do via a comment or email. If you look now, your update user should be offline in the OAC.

Unleash the daemons

This is the step that tripped me up. In the scripts directory there are a number of handlers and daemons that need to be running in order for everything to work properly. There’s also a handy little shell script that executes all the necessary daemons. You can run all the daemons at once by typing:

./startdaemons.sh

For some reason, I got errors when the script tried to open the files so I just started the daemons manually.

php xmppdaemon.php
php jabberqueuehandler.php
php publicqueuehandler.php
php xmppconfirmhandler.php
php smsqueuehandler.php
php ombqueuehandler.php

That should do it for getting the daemons running. If you look in your OAC again, your update user should be online.

Open ports

The final step is to open a few ports to outside access so users can communicate with your XMPP server. You need to open 5222, 5223, and 5296 for traffic to flow properly. If you’re going to need OAC access outside of your firewall, you have to open port 9090.

Caveats

Using the above methods, I was able to connect my Gmail account with the XMPP server and send updates successfully. However, another user who is using an afilliate Google account (ie john@doe.com signed up through Gmail) was unable to connect to the server.

Categories: How-To
Tags:, , ,



2 comments so far ↓

  • 1: Ben Madsen says:
    November 11th, 2008 at 12:54 pm

    The thing to be careful of is that Jabber (XMPP) IM accounts can only talk to other users that are local to that server unless the domains on both sides of the conversation have server to server properly configured ( http://tinyurl.com/5ec686 ). This is awfully difficult to do when you have a single email registered with Google’s service without the domain administrator’s help.

  • 2: Mark says:
    November 11th, 2008 at 9:39 pm

    Ben,
    That’s a really good point, one that I hadn’t considered. I haven’t had any problem with the setup shown above other than users of Google Apps for Your Domain aren’t able to connect to it. This could be why. Thanks for the link.