Ubuntu Touch: Make your own Jabber/XMPP app in 10 minutes…

You probably think that I’m joking, but I’m not. You can actually build a jabber/xmpp app in less than 10 minutes if you have a good internet connection, and have already set up your system with “clickable”. If not, be sure to check out my last post about it.

Are you ready to get started? Okay, here we go!

The magic that makes this work is that someone (or rather a group of someones) has already made a javascript xmpp client called convers.js. Head over to their website (https://conversejs.org/) and download it, or more directly, just click here: https://github.com/conversejs/converse.js/archive/v3.3.4.zip

Now jump over to your downloads folder and unzip it, or extract it if you grabbed the tar version. Great job, we are 20% done!

Open up your terminal and start typing:

$ mkdir xmmpapp
$ cd xmmpapp/
$ clickable init
Available app templates:
[1] pure-qml-cmake – Pure QML App (built using CMake)
[2] cmake – C++/QML App (built using CMake)
[3] python-cmake – Python/QML App (built using CMake)
[4] html – HTML App
[5] webapp – Simple Webapp
Choose an app template [1]: 4
Generating new app from template: HTML App
You’ve cloned /home/alaskalinuxuser/.cookiecutters/ut-app-html-template before. Is it okay to delete and re-clone it? [yes]: yes
Cloning into ‘ut-app-html-template’…
remote: Counting objects: 28, done.
remote: Total 28 (delta 0), reused 0 (delta 0), pack-reused 28
Unpacking objects: 100% (28/28), done.
Checking connectivity… done.
title [App Title]: xmppapp
description [A short description of your app]: xmpp app.
app_name [appname]: xmppapp
app_full_name [appname.yourname]: xmppapp.alaskalinuxuser
version [1.0.0]: 1.0.0
maintainer_name [Your FullName]: Alaskalinuxuser
maintainer_email [email@domain.org]:
Select open_source_license:
1 – GNU General Public License v3
2 – MIT license
3 – BSD license
4 – ISC license
5 – Apache Software License 2.0
6 – Not open source
Choose from 1, 2, 3, 4, 5, 6 [1]: 5
Your new app has been generated, go to the app’s directory and run clickable to get started

All we did was make a directory, run clickable, and choose to make a html app. Notice that this is not a web-app, which is basically a shortcut to some web site. This app is all on the users phone and just opens up an html file. We are now 40% done!

Open up your file manager. Find the downloads folder with your extracted convers.js files. In my case it is ~/Downloads/c/converse.js-3.3.4. Be sure to be in the folder, so you see the files like dev.html. In another tab or window, open up the place that you made your new app, in may case it is ~/ubports_apps/xmmpapp/xmppapp. Be sure to be in this folder so that you see the www folder.

Open the www folder, and drag all of the contents of the converse folder into it. It will ask you if you want to overwrite index.html, say yes. You are 60% done! Five minutes down, five minutes to go!

Now back to you (hopefully) still open terminal. You should still be in the folder outside of the folder of the app you just made. Change directory to your app, like so:

$ cd xmppapp/
$ ls
clickable.json manifest.json www xmppapp.desktop
LICENSE README.md xmppapp.apparmor

Typing the ls command should show the same files I have, if you named the app the same as I did. Plug in your phone and be sure developer mode is enabled with Settings->about->Developer mode. You are 80% there!

All you have left to do is type:

$ clickable


Copied files to temp directory for click building
Successfully built package in ‘./xmppapp.alaskalinuxuser_1.0.0_all.click’.
3724 KB/s (3190648 bytes in 0.836s)
Installing files [=========================]
Finished [=========================]
Installing files [=========================]
Starting [=========================]
Finished [=========================]
Installed xmppapp.alaskalinuxuser-1.0.0.all (installed:click,removable=1,app_name=xmppapp) summary goes here

And you are 100% done! If all went as well as it did here, you should see this:

And now you can start jabber-ing! Obviously, you need an account somewhere. Currently, with this setup, you are using conversjs.org’s BOSH server, and you can connect to your xmpp server. However, this should only be done for testing purposes.

To really utilize this app, you should set up your own BOSH server, and perhaps your own XMPP server. I use ejabber2, so it is an XMPP server and a BOSH server all in one. In the index.html file is this line:

bosh_service_url: ‘https://conversejs.org/http-bind/’,

which should point to your BOSH server. But for testing purposes, the above line works flawlessly. Just recognize that since you are borrowing their BOSH server, it may be down at their leisure, or they can give your sessions the boot if they so desire.

As is, this app will run a non-encrypted conversation with no issues at all. Encryption does work, but it seems a bit funky. I was able to have one successful encrypted conversation, and two that were failures at encrypting. One other issue is that when you close the app, your encrypted “tunnel” ends, so you need to re-establish encryption after that, and I think you have to make sure that the other user turns off encryption so you can re-encrypt with them again.

Big thanks to the convers.js team for making such a great java script that we could drop into our app!

Linux – keep it simple.

RWE: Ejabberd failed to start in Debian Wheezy

I had an old laptop that I decided would make a good toy for playing around with some lightweight server applications. It was a great candidate for several reasons. For one, I’m not using it for something else. Second, it was free. Third, it has a built in battery backup. Seemed like a win-win for me.

I’ve mentioned before that I am a member of SDF, the Super Dimensional Fortress (sdf.org), a free to the community Unix server that allows remote log in and numerous other goodies. Among those extras is the free jabber (XMPP) service for members. It’s really great, especially for free, but on several occaisions, it has been down for maintenance when I was waiting to receive a message to someone. That is a bit annoying. Obviously, server maintenance needs to happen, and I am really thankful to sdf.org for providing the service. I was just thinking that this would be a good excuse to try setting up my very own XMPP server.

Thus enter ejabberd. Ejabberd is an open source XMPP server that is available on most GNU/Linux distributions, including Debian Wheezy, which was already on my laptop. I looked up several tutorials on-line, and they all seemed to indicate that it would be super easy to set up, and I could get it up and running in a few minutes.


Two days latter…..

I finally got it set up and running. No matter which tutorial I followed, none of them worked. It took hours of research (in between being a dad, husband, working person, etc.), but I finally figured out the problem. Not too many people are planning to set up their own XMPP server, and this problem is probably specific to Debian Wheezy, but I figured that I would show you the REAL steps to get this going.

The problem was that after installing ejabberd, even with the default settings, it would say:

starting service: ejabbered………………………………………………………..FAILED.

And there was no rhyme or reason why! I was only able to figure it out by running ejabberd live, so the output came to the terminal, and then I could see the issue.

# apt-get install ejabberd

If you are like me, it will fail after install.

# dpkg-reconfigure ejabberd

Set up your server name, admin, etc.

# ps axc|grep beam

# ps axc|grep epmd

Now kill both of those processes.

# nano /etc/default/ejabberd

Uncomment the ERLANG_NODE=ejabberd line, or add it if it does not exist. Save and exit that file. Not having this line caused my first failure.

Edit your  /etc/hosts file to look like this: localhost

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Essentially, you need to delete any “extra” hosts in the file, just leave the localhost ones. Later, more can be added to the file once ejabberd is running, but for some reason, having extra hosts in this file cause my second failure.

Now you can start ejabberd. I recommend that the first time, you start it “live” so you can see what is happening under the hood:

# /etc/init.d/ejabberd live

But in the future, you can just start it with the usual services tags:

# service ejabberd restart

You should now have a running instance of ejabberd! Of course, now you need to add a user, if you didn’t already. Here is an example:

# ejabberdctl register userName xmppServerAddress.net superSecretPassword

And there we go! At least for me, that was enough to set up a fully functional XMPP server with ejabberd on Debian Wheezy. Of course, this still needs tuning and enabling features like blocking, encryption, etc., but hey, at least now you have something to work with!

Linux – keep it simple.