Quick install steps to get MyQttD installed (Linux/Unix)


1. Introduction

The following notes are designed as a quick install steps to quickly have libMyQtt and MyQttD installed.

Please, always refer to the following page to find ready to use packages for your distribution:


2. Getting dependencies installed

Get into the directory you would like to have your sources compiled. In our case, we will use /usr/src/.

Let's have libaxl installed (xml and infrastructure):

>> cd /usr/src
>> svn co https://dolphin.aspl.es/svn/publico/af-arch/trunk/libaxl
>> cd libaxl
>> ./autogen.sh --prefix=/usr --sysconfdir=/etc
# previous command should finish without issues, fix all reported problems
>> make
# last make should finish Ok ;-)
>> make install

Now, let's have noPoll installed:

>> cd /usr/src
>> svn co https://dolphin.aspl.es/svn/publico/nopoll/trunk nopoll
>> cd nopoll
>> ./autogen.sh --prefix=/usr --sysconfdir=/etc
# previous command should finish without issues, fix all reported problems
>> make
# last make should finish Ok ;-)
>> make install

3. Installing libMyQtt and MyQttD sources and files:

>> /usr/src
>> svn co https://dolphin.aspl.es/svn/publico/myqtt
>> cd myqtt
>> ./autogen.sh --prefix=/usr --sysconfdir=/etc
# previous command should finish without issues, fix all reported problems
>> make
# last make should finish Ok ;-)
>> make install

NOTE: reached this point, you already have libMyQtt. If that's you want, you are done. Now check the following manuals to get started with libMyQtt:

If you need to have MyQttD up and running, keep on reading

4. Getting MyQttD up and running with all modules enabled and a set of users

Let's create default configuration from example installed:

>> cd /etc/myqtt/
>> mv myqtt.example.conf myqtt.conf

Now, open the file with a file editor /etc/myqtt/myqtt.conf and do the following changes:

5. Enabling some modules

>> cd /etc/myqtt/web-socket
>> mv web-socket.example.conf web-socket.conf
>> cd /etc/myqtt/ssl
>> mv ssl.example.conf ssl.conf
>> cd /etc/myqtt/mods-enabled
>> ln -s ../mods-available/mod-ssl.xml
>> ln -s ../mods-available/mod-web-socket.xml
>> ln -s ../mods-available/mod-auth-xml.xml
>> ln -s ../mods-available/mod-status.xml

6. Creating a domain for your work

For that, create the directory refered by the configuration:

>> mkdir /etc/myqtt/domains.d

Now, create a file with the following format, matching a domain where you want to group a set of users, storage and configuration, for example: /etc/myqtt/domains.d/myqtt.yourdomain.com

Inside, it should have something like:

<domain use-settings="basic" 
        name="myqtt.yourdomain.com" />

Of course update the content of the file and directory paths to match your scenario. After than, create directories like this and assign permissions to the right user:

>> mkdir -p /var/lib/myqtt-dbs/myqtt.yourdomain.com /var/lib/myqtt/myqtt.yourdomain.com
>> chmod og-rwx /var/lib/myqtt-dbs/myqtt.yourdomain.com /var/lib/myqtt/myqtt.yourdomain.com
>> chown myqttd:myqttd /var/lib/myqtt-dbs/myqtt.yourdomain.com /var/lib/myqtt/myqtt.yourdomain.com

7. Creating a user/client id to authenticate

Now, it only remains to create a user to authenticate (or just the client_id whatever your prefer). For that, create the following file: /var/lib/myqtt-dbs/myqtt.yourdomain.com/users.xml

...and declare users you want to be recognized like this:

<myqtt-users password-format="plain" >
   <user id="test_01" />
   <user id="test_04" />
   <user password="differentpass" 
         id="test_02" />
   <user password="differentpass" 
         id="another-id-03" />

8. Test server configuration

Now, to test everything before leaving it running in background run:

>> myqttd --color-debug

It should start and report something like:

I: Myqttd STARTED OK (pid: 32435, myqtt ctx refs: 11)
Some errors my appear associated to missing certificates. You can ignored them for know but in the case you need MQTT over WebSocket TLS or TLS-MQTT, you'll have to configure them.

Now, connect in with a client to publish some messages. For that, using the client id, user and passsword if have created, subscribe to a topic:

>> myqtt-client --host localhost --port 1883 --client-id test_01 --subscribe "0,myqtt/this/is/a/test"

Now, in the same terminal, login and let the client wait and print incoming messages:

>> myqtt-client --host localhost --port 1883 --client-id test_01 --get-msgs

Now, in a different terminal, with a different client id, publish:

>> myqtt-client --host localhost --port 1883 --client-id test_01 --publish "0,myqtt/this/is/a/test,This is a test message"

9. Configuring automatic server start on boot

Now everything is running as expected, you can configure the init.d script to have it started on every boot up by doing something like:

>> cd /usr/src/myqtt
>> cp doc/myqtt-init.d /etc/init.d/myqtt
>> chmod +x /etc/init.d/myqtt
>> /etc/init.d/myqtt restart

Now you can see logs at syslog, with something like:

>> tail -f /var/log/syslog

That's all, now you should have MyQttD running in your box. See the following resources for further reading: