Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mosquitto » How To Install Mosquitto On Debian Stretch-Based Linux Distros(Dependency specifications in the current package cause installation to fail. This article describes a workaround.)
How To Install Mosquitto On Debian Stretch-Based Linux Distros [message #1773991] Sun, 08 October 2017 11:59 Go to next message
David DickinsonFriend
Messages: 1
Registered: October 2017
Location: New Mexico, USA
Junior Member
Eclipse Mosquitto (h##p://wiki.eclipse.org/Mosquitto) is a popular open-source implementation of the MQTT protocol for Linux embedded devices and low power machines. It runs well on Raspbian Jessie devices. But with the release of the Debian Stretch-based version of Raspbian, the popular operating system for Raspberry Pis, installing Mosquitto from the repository or by the usual build-from-source methods will fail. The current version 1.4.12 that is available from the Raspbian repository contains references to dependencies that cause installation to fail.

This manual describes how to overcome these problems and get Mosquitto up and running on your Raspbian Stretch-based Raspberry Pi.

Quote:
WARNING: At the time of this writing, you should not be running a version of Eclipse Mosquitto older than 1.4.12 due to a security issue in earlier versions. See CVE-2017-7650 at h##ps://mosquitto.org/2017/05/security-advisory-cve-2017-7650/.


The Problem

Users who were running Raspbian Jessie when they installed Mosquitto and who then upgraded to Stretch have no problems. The problems occur on fresh installations of Raspbian Stretch or on devices on which Mosquitto had not been previously installed, even if they were upgraded from Jessie to Stretch:

sudo apt-get install mosquitto
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
mosquitto : Depends: libssl1.0.0 (>= 1.0.1) but it is not installable
Depends: libwebsockets3 (>= 1.2) but it is not installable


You cannot install libssl1.0.0 or libwebsockets3 because they aren't available in the repository. Besides, especially for OpenSSL, you always want to be running the latest versions, which at the time of this writing are v1.0.2 (the newest long term support version) and 1.1.1 (the latest stable version).

Quote:
WARNING: At the time of this writing, you should not be running versions of OpenSSL older than 1.0.2m (LTS version) or 1.1.0g (stable version). See CVE-2017-3735 at h##ps://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-3735.


For websockets, the version available in the Raspbian repo is libwebsockets8, but the attempt to install Mosquitto fails because it is looking for libwebsockets3. Both of these problems exist because the developers of those dependencies included the version in the name of the package, such as "libssl1.0.0" instead of simply "libssl". Dependent packages, which would otherwise work very well with newer versions of the code, search for a name containing numerals, but deprecated versions have been removed from the repositories.

A similar problem exists if you try to install the mosquitto-clients package:

sudo apt install mosquitto-clients
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
mosquitto-clients : Depends: libmosquitto1 (= 1.4.12-0mosquitto1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
root@raspi3:/home/pi#


Here, the dependency is on libmosquitto1, which cannot be installed because of dependencies on libc-ares2, as well as on libssl1.0.0, which is discussed above. The package libc-ares2 is actually available in the repository and can be installed separately. (We will not investigate why this error appears.)

Prerequisites

First of all, you must decide if you want support for web sockets in your MQTT installation. There are two versions of mosquitto, libmosquitto1, and mosquitto-clients that will be explained here:


  • v1.4.12 which has support for web sockets
  • v1.4.14 which does not support web sockets ("~nows1" appears in the filenames)


If you're planning on subscribing or publishing to MQTT using Javascript, you want web sockets.
You must also decide which version of OpenSSL you are or will be using. There are two series: the long-term service series, which is currently at v1.0.2, and the stable series, now at version 1.1.

Fixing The Broker

We'll work on the mosquitto broker first. Follow these steps:

Create a work folder. For this example, we will use /home/pi/mosquitto:

mkdir mosquitto
cd mosquitto


Download the latest version. Aside from the development and debug versions, you'll see two versions of the broker for armhf devices shown at the repo, which is at

h##p://repo.mosquitto.org/debian/pool/main/m/mosquitto/

One version, v1.4.12, has support for web sockets. Version 1.4.14, however, does not, as indicated by the "~nows1" in the filename. We'll cover fixing both versions here, so we need to download both of them. You should download only the one that you need.

wget h##p://repo.mosquitto.org/debian/pool/main/m/mosquitto/mosquitto_1.4.12-0mosquitto1_armhf.deb # Supports web sockets

or, if you don't need web sockets support:

wget h##p://repo.mosquitto.org/debian/pool/main/m/mosquitto/mosquitto_1.4.14-0mosquitto1~nows1_armhf.deb # Does NOT support web sockets

We'll create new subdirectories for working on the broker, one for the version with web sockets support and one without it, and extract the raw contents of the package into them:

mkdir brokerws
dpkg-deb R mosquitto_1.4.12-0mosquitto1_armhf.deb brokerws


or

mkdir brokernows
dpkg-deb R mosquitto_1.4.14-0mosquitto1~nows1_armhf.deb brokernows


Now we must edit the control file to fix the reference to the non-existent dependency.

nano brokerws/DEBIAN/control

or

nano brokernows/DEBIAN/control

For the version supporting web sockets, in the line beginning with "Depends:" are the two entries that we're concerned with here:


  • libssl1.0.0 (>= 1.0.1)
  • libwebsockets3 (>= 1.2)


If you're using the long-term support branch of OpenSSL, then you should change the dependency to "libssl1.0.2 (>= 1.0.2)". For the stable version, change it to "libssl1.1 (>= 1.1)".

Quote:
WARNING: The versions of libssl that are available in the repository are NOT patched for CVE-2017-3735. This article assumes that you're maintaining them yourself. If you're reading this when the versions given here are removed from the repository and replaced with newer versions, make changes to the above entries that are appropriate.


Similarly, change the web sockets library entry to "libwebsockets8 (>= 2.0.3)". If you're working on mosquitto v1.4.14 without web sockets support, you can skip this step.

Make a note of the other dependencies. We'll have to make sure that they're installed later. Save the file with CTRL-x and exit nano.

Now we want to repackage the fixed version:

dpkg-deb b brokerws mosquitto_1.4.12-0mosquitto1_armhf-FIXED.deb

Or

dpkg-deb b brokernows mosquitto_1.4.14-0mosquitto1~nows1_armhf-FIXED.deb

Basically, we're just appending "-FIXED" to the original file name. You can now delete the original files and the broker* folder.

Fixing the Mosquitto Library

The library and client packages for Mosquitto, libmosquitto1 and mosquitto-clients, both suffer from the same dependencies. As well, there are two versions of interest, v1.4.12 with web sockets support, and v1.4.14 without it. However, it is not necessary to make any changes to mosquitto-clients, since its installation fails only because the installation of its dependency fails. When libmosquitto1 is fixed, the client can be installed successfully.

The procedures for fixing the errant dependency in libmosquitto1 are the same as those given above for the broker: Change the dependency on "libssl1.0.0 (>= 1.0.0)" to either the long-term service version or the stable version that actually exists in the repository. USE THE SAME VERSION THAT YOU USED FOR THE BROKER, ABOVE. In addition, make sure that you use the correct version of the library for the version of the broker that you want to install, either Mosquitto v1.4.12 or v1.4.14.

Installation

Make sure that you have Openssl (libssl1.1 or libssl1.0.2) installed. Install the version that you specified in the control file.

We must also make sure that these other dependencies are installed. You can check if what you have installed or what is available using this command:

sudo apt-cache policy <package name>

• adduser (>= 3.10) (At least version 3.115 may be already installed.)
• libuuid1 (>= 2.16) (At least version 2.29.2-1 may be already installed.)
• lsb-base (>=4.1+Debian3) (At least version 9.20161125+rpi1 may be already installed.)
• libwebsockets8 (>= 2.0.3) (if you need it for Mosquitto 1.4.12 only)
• libwrap0 (>= 7.6.4~) (At least version 7.6.q-26 may be installed. This should work.)
• libc-ares2 (>= 1.7.0) (You may have to install it.)
• libc6 (>= 2.15) (At least version 2.24.11+deb9u1 may already be installed.)

You must install the version of libmosquitto1 that is appropriate to the version of mosquitto and mosquitto-clients that you're going to install, and that depends on whether or not you need web sockets support. Pick one version for all three, either v1.4.12 or v1.4.14. Don't mix versions.

Install the fixed packages using this command:

sudo dpkg i <filename>

Select the packages by version number, using v1.4.12 if you need web sockets support, or v1.4.14 if you don't. Install the packages in this order:

1. libmosquitto1
2. mosquitto
3. mosquitto-clients (We'll use them to test the installation.)

Testing

Now, we can test the installation. Open a terminal window (we'll be using three terminal windows) and do the following:

pi@home:~ $ sudo /etc/init.d/mosquitto stop
[ ok ] Stopping mosquitto (via systemctl): mosquitto.service.
pi@home:~ $ sudo /etc/init.d/mosquitto start
[ ok ] Starting mosquitto (via systemctl): mosquitto.service.
pi@home:~ $ mosquitto v


Now, in a new terminal window, we'll subscribe to the topic "hellow/world":

pi@home:~ $ mosquitto_sub -d -t hello/world

Back in the first terminal window, we'll publish a message:

pi@home:~ $ mosquitto_pub -d -t hello/world -m "Hello from Mosquitto!"
Go back to the subscription window, and you should see something similar to the following:
pi@home:~ $ mosquitto_sub -d -t hello/world
Client mosqsub|1154-raspi3 sending CONNECT
Client mosqsub|1154-raspi3 received CONNACK
Client mosqsub|1154-raspi3 sending SUBSCRIBE (Mid: 1, Topic: hello/world, QoS: 0)
Client mosqsub|1154-raspi3 received SUBACK
Subscribed (mid: 1): 0
Client mosqsub|1154-raspi3 received PUBLISH (d0, q0, r0, m0, 'hello/world', ... (21 bytes))
Hello from Mosquitto!
Client mosqsub|1154-raspi3 sending PINGREQ
Client mosqsub|1154-raspi3 received PINGRESP


If you see "Hello from Mosquitto!", then your installation is working correctly, and it's time for a sandwich.
Re: How To Install Mosquitto On Debian Stretch-Based Linux Distros [message #1775697 is a reply to message #1773991] Fri, 03 November 2017 15:34 Go to previous messageGo to next message
Alain Charest is currently offline Alain CharestFriend
Messages: 1
Registered: November 2017
Junior Member
Hi,

I did all of that and was able to publish messages.
The problem I still have is that if I use:
mosquitto_sub -d -u username -P password -t dev/test
(username is username and password is password)
I get: Error: Connection refused

There are a lot of blogs where people have problem with authentification on Debian Stretch .
mosquitto version 1.4.12 MQTT v3.1.1/v3.1 broker
Re: How To Install Mosquitto On Debian Stretch-Based Linux Distros [message #1782790 is a reply to message #1773991] Thu, 01 March 2018 13:15 Go to previous messageGo to next message
Ulf Holt is currently offline Ulf HoltFriend
Messages: 1
Registered: March 2018
Junior Member
I have tried to follow your advice. Thank you so much for the guide!

There are two issues:

1. Version 1.4.12 is not available from the source you listed. I need support for web socket - will version 1.4.15 support support this (you say version 1.4.14 will not) or shoud I use 1.4.10?

2. tried to dowload version 1.4.15 as a test, but the command
dpkg-deb R mosquitto_1.4.15-0mosquitto1~nows1_armhf.deb brokernows failed with an error there was something wrong with the command

Best regards

Ulf
Re: How To Install Mosquitto On Debian Stretch-Based Linux Distros [message #1784935 is a reply to message #1782790] Fri, 06 April 2018 05:17 Go to previous message
Jimmy Saldivias is currently offline Jimmy SaldiviasFriend
Messages: 1
Registered: April 2018
Junior Member
Answering your question:
"but the command
dpkg-deb R mosquitto_1.4.15-0mosquitto1~nows1_armhf.deb brokernows failed with an error there was something wrong with the command"
What is wrong with it, that the command is missing "-" before R.
Corrected version is:
dpkg-deb -R mosquitto_1.4.15-0mosquitto1~nows1_armhf.deb brokernows
Previous Topic:TLS SSL Socket error on client , disconnecting
Next Topic:Mosquitto acl_file "topic readwrite #" breaking permissions
Goto Forum:
  


Current Time: Wed Sep 26 14:45:05 GMT 2018

Powered by FUDForum. Page generated in 0.01710 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top