Using to create your own Jabber server

While I've been having fun consolidating accounts for email and social networks, I've been looking for a way to simplify my instant messaging services.

While I use iCloud to deliver my text messages and FaceTime calls between my iPhone, iPad and MacBook Pro, I still needed a way to consolidate the hefty amount of Google Talk contacts I have. Fortunately, Google Talk is based off XMPP so it's very portable. Since deleting my Gmail account, I needed a Jabber ID (JID) that didn't reflect a nonexistent email address.

So I knew was going to use Jabber as my protocol of choice, since it was the most extensible platform for instant communication. The question was, where was I going to get the ability to use my email address (or more importantly, my domain - as my JID? Since moving hosting from Dreamhost to a VPS with 6sync, I no longer had the option to let my host manage my JID needs. I needed to run my own solution. Enter Prosody.

A friend was going through a similar situation and the solution he found was Prosody. Prosody is a lightweight XMPP communications server that is a breeze to download and install. While it is available cross-platform, my VPS runs Ubuntu. With a little apt-get action in the command line, I had the package downloaded, installed and configured within about an hour - including the time it took to build the SRV records for my domain. When you add the package repository to your install, it is even easier to stay on top of updates when you apt-get update.

Most of the configuration is done through /etc/prosody/prosody.cfg.lua. Once you've configured the global settings for the service, it's time to build a virtual host file for the domain you want to use it with. It's a simple as creating a file with the name of the root hostname (i.e., in the /etc/prosody/conf.d directory.

After you configure the service and the hostnames, it's time to build your user account. I wanted mine to mirror my email address for simplicity's sake. Fortunately, building user accounts in Prosody is even easier than the service configuration. For all instances of Prosody (except for Windows), you can use prosodyctl at the command line to build the accounts. It even supports batch uploading and conversion from services like ejabberd.

Once you have the basics down, you can get fancy by adding components. Components let you do cool things like create and use chat rooms on the service, maintain user directories or forge gateways to other protocols like AIM/ICQ, Yahoo! or MSN. Because of how XMPP was created, you don't have to worry about federating your domain to other services like you do with Office Communicator Server (OCS) or private implementations of XMPP (like the one built into Mountain Lion Server).

I have yet to find a limitation to what Prosody can do and it's great with RAM consumption (currently, it's using around 1% of my VPS's available RAM). It's pretty extensible, but you'll need to either be running your own in-house server or have full root access to a VPS box in the cloud. Prosody won't run on shared hosting, since you don't have full permissions to install files or full access to the directories necessary to set up the service.

The best part of using XMPP for instant messaging is that there are a myriad of clients out there that support the protocol on all three desktop operating systems. iChat, Messages, Adium, and others are all ready to fully support JID's and have done so for quite some time.

A word about XMPP and Facebook Chat

Facebook chat famously uses XMPP so that any Jabber chat client (iChat, Messages, Adium, etc.) can be used to connect to the service. However, in my testing, I found that trying to import Facebook users to another standard XMPP client will not work. Why? Facebook's developer page for the chat API states,

Because roster items and presence subscriptions are based on the user's Facebook friends, they cannot be created or deleted using the standard XMPP mechanisms.

Essentially, because you're authorized to view your friends statuses, you're also authorized to chat with them. If you're not linked directly to someone through friend request, you won't be able to chat with them. The friend request is the mechanism that grants you the XMPP chat authorization. It's as simple as that.

The reason I wanted to port over some Facebook users to my regular Prosody-hosted JID is because that's sometimes the only way I have to contact certain users. People may not necessarily use instant messaging services, but by default, Facebook users always use Facebook chat. However, because of Facebook's arbitrary (and, from a privacy standpoint, decidedly useful) way of authorizing contacts, you cannot simply drag-and-drop contacts into your Prosody-hosted account. The two services, despite being built on the same XMPP code will not talk to each other.

Blame Facebook.