Six Steps to install mosquitto 1.4.2 with websockets on debian wheezy.

Latest versions of mosquitto (since 1.4) include the websockets interface, but the binary download available from the website does not. So you have to download the source code and build the packet your own, last you have to configure mosquitto to use websockets.

In the following few lines I’m going to show to you how to build and configure mosquitto with websockets on a clean debian wheezy distro.

Step 1 – Let’s start preparing the build system

Step 2 – Download and build libwebsockets
Latest version of libwebsockets prevents mosquitto to be built, so I’m going to use version 1.4 of libwebsockets:

 mosquitto_mqtt
Step 3 – Download and build mosquitto 1.4.2

Edit config.mk changing the line

to
WITH_WEBSOCKETS:=yes

Step 4 – Configure mosquitto to use websockets
Add the following lines to /etc/mosquitto/mosquitto.conf in the “Default Listener” section:

So your config file should look like the following:

Step 5 – Last steps

Step 6 – Run mosquitto

Now you are ready to run your websockets application against mosquitto.
Gg1

If you’ve found useful this post, please, make a visit to my linkedin profile gg1 to help me growing my ranking.

Releated Post

20 thoughts on “Six Steps to install mosquitto 1.4.2 with websockets on debian wheezy.

  1. Great guide and very easy to follow!
    Do you know if there is an easy way to update mosquitto after installment?
    Or I guess maybe, due to the libwebsockets, you have to rebuild mosquitto.

  2. after done all of steps without errors when I run
    mosquitto -c /etc/mosquitto/mosquitto.conf
    I got error below:
    bash: mosquitto: command not found
    there is no mosquitto in my machine. please let me know how to fix it

  3. Hi Tommy,
    are you sure the “make install” commands were executed fine?
    try issueing them using sudo
    $ sudo make install

  4. hi admin,

    I found out problem, because I used root user, so I can not execute mosquitto, to execute it, I need to add user.

    any ways thank you.
    Tommy

  5. Hi,
    I get the following error when I try to execute make command:

    set -e; for d in lib client src; do make -C ${d}; done
    make[1]: Entering directory ‘/home/pi/mosquitto-1.4.7/lib’
    cc -Wall -ggdb -O2 -I. -I.. -I../lib -fPIC -DWITH_TLS -DWITH_TLS_PSK -DWITH_THREADING -DWITH_SOCKS -DWITH_SRV -c srv_mosq.c -o srv_mosq.o
    In file included from /usr/include/arm-linux-gnueabihf/sys/param.h:31:0,
    from /usr/include/arpa/nameser.h:59,
    from srv_mosq.c:20:
    /usr/include/arm-linux-gnueabihf/bits/param.h:28:25: fatal error: /usr/include/linux/param.h: Input/output error
    #include
    ^
    compilation terminated.
    Makefile:84: recipe for target ‘srv_mosq.o’ failed
    make[1]: *** [srv_mosq.o] Error 1
    make[1]: Leaving directory ‘/home/pi/mosquitto-1.4.7/lib’
    Makefile:21: recipe for target ‘mosquitto’ failed
    make: *** [mosquitto] Error 2

  6. I’ve just compiled version 1.4.7 running the above procedure on debian wheezy. It works fine.

    For your problem…
    it seems you have to install linux-libc-dev on your raspberry pi distro.

  7. Hi,
    I’m getting errors
    1457431305: Config loaded from /etc/mosquitto/mosquitto.conf.
    1457431305: Opening websockets listen socket on port 9001.
    Segmentation fault (core dumped)
    After running step 6. I’m not sure that because I’ve skipped Step 5 is the cause or not. Has anyone experienced this error yet ?
    Thank you

  8. ‘libwebsockets-1.4-chrome43-firefox-36.tar.gz’ while extracting gives unexpectec end of file error. Will it work with any other version? I tried downloading latest libwebsocket from github but it gives error while ‘make’ and ‘make install’ of Mosquitto??
    Please help!

  9. Hi,
    after I followed and done all steps.
    it shows

    root@raspberrypi:/home/pi# mosquitto -c /etc/mosquitto/mosquitto.conf
    Error: Websockets support not available.
    Error found at /etc/mosquitto/mosquitto.conf:138.
    Error: Unable to open configuration file.

    what should I do now? (I’m a starter in linux sorry).

  10. couldn’t get through the set up. I got to:
    wget http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/snapshot/libwebsockets-1.4-chrome43-firefox-36.tar.gz with a response of:
    http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/snapshot/libwebsockets-1
    connecting to git.libwebsockets.org (git.libwebsockets.org)|163.172.24.82|:80… connected.
    HTTP request sent, awaiting response…Read err (connection reset by peer) in headers.

    This repeated for 20 trys and gave up.

Leave a Reply

Your email address will not be published. Required fields are marked *