Tuesday, May 22, 2012

Setting up Ejabberd

For the Android app I've been developing, I've been using OpenFire as the back end for development purposes. Openfire was chosen mostly for convenience, but I didn't plan on using it for production as it costs when number of user scales up.
I did a bit of research and settled on ejabberd for my production server. Installing the server was as painless as it can get:


sudo apt-get install ejabberd


Note that this will install the ejabberd from the repository, which may not be the latest. I did grab the latest copy, but had problem install it.


After installation completes, I had to do some custom configuration.
Stop ejabberd first:


sudo /etc/init.d/ejabberd stop


Open the cfg file:


sudo vi /etc/ejabberd/ejabberd.cfg


For debugging purposes, I enabled debug log:


{loglevel, 4}


Set the admin user:


{acl, admin, {user, "ricky", "password"}},


Set the host. Since I repurposed another PC at home, I just set the host to its IP address:


{hosts, ["192.168.1.101"]},


For my application, I also needed to enable user directory search:


{mod_vcard, [{host, "search.192.168.1.101"}]},


That's it. To restart the server:


sudo /etc/init.d/ejabberd start


To view the log, you can:


tail -f /var/log/ejabberd/ejabberd.log


Another useful feature is to dump the current database: 


sudo ejabberdctl dump /tmp/ejabberd_dump


You can Google ejabberdctl command to see the exhaustive command set. 


I'm also using asmack for the client. I'll put up some other posts in the future regarding asmack. 

No comments:

Post a Comment