Help installing mosquitto

Hi

I’m trying to follow the BRUH tutorial on installing mosquitto but my lack of linux knowledge means I’m hitting a brick wall at step 1.

When I try to install it says I’m missing ‘libwebsockets3’. I tried to remedy this by asking it to install libwebsockets3 but perhaps I didn’t format my request right or something.

Anyway here is what I have been putting into terminal, any suggestions much appreciated!
pi@hassbian:~ $ 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: libwebsockets3 (>= 1.2) but it is not installable
N: Ignoring file 'pwfile' in directory '/etc/apt/sources.list.d/' as it has no filename extension
N: Ignoring file 'mosquitto-stretch.list.1' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
E: Unable to correct problems, you have held broken packages.
pi@hassbian:~ $ sudo apt-get install libwebsockets3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libwebsockets3 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

N: Ignoring file 'pwfile' in directory '/etc/apt/sources.list.d/' as it has no filename extension
N: Ignoring file 'mosquitto-stretch.list.1' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
E: Package 'libwebsockets3' has no installation candidate

edit: fixed formatting

Always update your apt before hitting install. (have you edited your sources.list?

sudo apt-get update

This is likely to be the problem. It should be called /etc/apt/sources.list.d/mosquitto-stretch.list and contain

deb http://repo.mosquitto.org/debian stretch main

Which tells apt-get to fetch the file from the mosquitto archives, rather than the debian archives. The debian archives seem to have problems for mosquitto at the moment.

edit: See this link for reference Redirecting...

Thanks I had run apt-get update before I tried.

I’m not sure how edit sources.list soi presume I haven’t

Thanks - I read through that link and tried to follow the instructions but it didnt work.

The last comment in that thread says:
This page needs an update for Debian/Raspbian Stretch.

/etc/apt/sources.list.d file to fetch with wget is http://repo.mosquitto.org/debian/mosquitto-stretch.list

I’m not sure what this means/how to do it - any suggestions?

I fear my attempts at copying solutions from the internet are making things worse - I now have more errors when I attempt to install:

pi@hassbian:/etc/apt/sources.list.d $ sudo apt-get install mosquitto
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libwebsockets3 : Depends: libssl1.0.0 (>= 1.0.0) but it is not going to be installed
 mosquitto : Depends: libssl1.0.0 (>= 1.0.1) but it is not going to be installed
N: Ignoring file 'pwfile' in directory '/etc/apt/sources.list.d/' as it has no filename extension
N: Ignoring file 'mosquitto-stretch.list.1' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
N: Ignoring file 'mosquitto-jessie.list.1' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
N: Ignoring file 'mosquitto-stretch.list.2' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

That just means that to get the correct file for stretch (the latest debian release) you need to do

$ sudo wget http://repo.mosquitto.org/debian/mosquitto-stretch.list 

Since you already have something with that name, I think you have it.

Before you go any further, I would suggest using hassio to install HA. It was designed for people who struggle with the command line, and I know there is a mosquitto addon that makes installation straightforward.

If you can’t use hassio for some reason (and there are good reasons not to), here is how I suggest you proceed.

It has just occurred to me to check that you are on the latest OS release (and for that matter on a Raspberry Pi). How and when did you install your software?

1 Remove the existing mosquitto
I am not sure if it has already been forced to install, but do this anyway so you are starting from something clean

$ sudo apt-get remove mosquitto

2 Remove the extra files from /etc/apt/sources.list.d/
The wget command only needs to be run once, to get the one file that contains the location of where to get mosquitto for the stretch release. Since there are more than one, I expect that you have run the command more than once, which creates unnecessary files.

sudo rm /etc/apt/sources.list.d/mosquitto-stretch.list.1 /etc/apt/sources.list.d/mosquitto-stretch.list.2  /etc/apt/sources.list.d/mosquitto-jessie.list.1 pwfile

Now you should have one file in /etc/apt/sources.list.d called mosquitto-stretch.list, and nothing else from mosquitto

$ ls /etc/apt/sources.list.d/
mosquitto-stretch.list  raspi.list

This file should have this in it

$ cat  /etc/apt/sources.list.d/mosquitto-stretch.list 
deb http://repo.mosquitto.org/debian stretch main

Once you get to this point we can go on.

Good Luck :grinning:

Thanks for being so patient and helpful!

Yes I am running a raspberry pi (1 b). Months ago I had tried a hass.io install but the old pi doesnt have enough ram to install any add on components (SMB, etc). A few other people reported the same problem in a thread I made.

I then used Hassbian to install home assistant (which was relatively simple!)

Your instructions to clean up my mess were great. I’ve now removed all the rogue files, and I’m up to the point where I only have the files you mention.

ls /etc/apt/sources.list.d/ returns:
mosquitto-stretch.list raspi.list

and cat /etc/apt/sources.list.d/mosquitto-stretch.list returns:
deb http://repo.mosquitto.org/debian stretch main

I use a Pi 1 B+, so I guess I would have the same problem with hassio.

But I am concerned about which version of the OS you have, if you installed a few months ago. Hassbian changed to using stretch fairly recently, so unless you upgraded the os yourself, you are likely to still have the jessie version, in which case you are likely to see the sort of problems you are.

I’m can’t think of a command to check which version you are using, but if type python3 on the command line, which version of python does it report?
jessie had version 3.4 whereas stretch has version 3.5

If you are still on jessie it may be worth upgrading before going further, as python 3.4 not be enough to run HA something in the new year.

Edit: And I have just thought, I understood hassbian has a script to install mosquitto. Have you tried that?

Try using the mosquitto install script from here:

The command below:

sudo hassbian-config install mosquitto
1 Like

Depending on what version you are using, you may need to remove the /etc/apt/sources.list.d/mosquitto-stretch.list file in order to get the hassbian script to work, as that file may tell apt to fetch mosquitto from the wrong place.

Thanks Graham - I’m running the stretch version

pi@hassbian:~ $ uname -a
Linux hassbian 4.9.41+ #1023 Tue Aug 8 15:47:12 BST 2017 armv6l GNU/Linux
pi@hassbian:~ $ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 9.1 (stretch)
Release:	9.1
Codename:	stretch
pi@hassbian:~ $ python3 --version
Python 3.5.3

when I was originally trying to install mosquitto I tried the script - but it failed due to the error about dependencies.

I will give it another go now that you have helped me fix all the other errors I managed to introduce!

I re-tried the hasbian mosquitto install script without any luck.

I seem to be getting an error that it is ignoring ‘mosquitto-stretch.list.1’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension; a pubic key is now available and it can’t install libwebsockets3 dependency.

I copied the full output below.

pi@hassbian:~ $ sudo hassbian-config install mosquitto
Mosquitto Installer for Hassbian
Copyright(c) 2016 Dale Higgs <https://gitter.im/dale3h>
Modified by Landrash for use with Hassbian.
Adding mosquitto user
The system user `mosquitto' already exists. Exiting.
Creating pid file
Creating data directory
Installing repository key
--2017-11-20 07:07:38--  http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
Resolving repo.mosquitto.org (repo.mosquitto.org)... 85.119.83.194, 2001:ba8:1f1:f271::2
Connecting to repo.mosquitto.org (repo.mosquitto.org)|85.119.83.194|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3137 (3.1K) [application/octet-stream]
Saving to: ‘STDOUT’

-                   100%[===================>]   3.06K  --.-KB/s    in 0s      

2017-11-20 07:07:40 (32.2 MB/s) - written to stdout [3137/3137]

OK
Adding repository
--2017-11-20 07:07:41--  http://repo.mosquitto.org/debian/mosquitto-stretch.list
Resolving repo.mosquitto.org (repo.mosquitto.org)... 85.119.83.194, 2001:ba8:1f1:f271::2
Connecting to repo.mosquitto.org (repo.mosquitto.org)|85.119.83.194|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50 [application/octet-stream]
Saving to: ‘mosquitto-stretch.list.1’

mosquitto-stretch.l 100%[===================>]      50  --.-KB/s    in 0s      

2017-11-20 07:07:42 (618 KB/s) - ‘mosquitto-stretch.list.1’ saved [50/50]

Installing mosquitto
Get:1 http://ftp.debian.org/debian jessie-backports InRelease [166 kB]         
Hit:2 http://repo.mosquitto.org/debian stretch InRelease                       
Get:3 http://mirrordirector.raspbian.org/raspbian stretch InRelease [15.0 kB]  
Hit:4 http://archive.raspberrypi.org/debian stretch InRelease                  
Ign:1 http://ftp.debian.org/debian jessie-backports InRelease                  
Fetched 181 kB in 14s (12.2 kB/s)
Reading package lists... Done
N: Ignoring file 'mosquitto-stretch.list.1' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
W: GPG error: http://ftp.debian.org/debian jessie-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 7638D0442B90D010
W: The repository 'http://ftp.debian.org/debian jessie-backports InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: Target Packages (main/binary-armhf/Packages) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list:5
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list:5
W: Target Translations (main/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list:5
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list:5
W: Target Packages (main/binary-armhf/Packages) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list:5
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list:5
W: Target Translations (main/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list:5
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:4 and /etc/apt/sources.list:5
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libwebsockets3 : Depends: libssl1.0.0 (>= 1.0.0) but it is not going to be installed
 mosquitto : Depends: libssl1.0.0 (>= 1.0.1) but it is not going to be installed
 mosquitto-clients : Depends: libmosquitto1 (= 1.4.12-0mosquitto1) but it is not going to be installed
N: Ignoring file 'mosquitto-stretch.list.1' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
Writing default configuration
/opt/hassbian/suites/install_mosquitto.sh: line 48: cd: /etc/mosquitto: No such file or directory
mv: cannot stat 'mosquitto.conf': No such file or directory
cp: cannot create regular file '/etc/mosquitto/mosquitto.conf': No such file or directory
chown: cannot access 'mosquitto.conf': No such file or directory
Initializing password file

Please take a moment to setup your first MQTT user
If no choice is made a default account will be created

Username: mqtt
Password: 
Creating password entry for user mqtt
/opt/hassbian/suites/install_mosquitto.sh: line 77: mosquitto_passwd: command not found
Restarting Mosquitto service
Failed to restart mosquitto.service: Unit mosquitto.service not found.

Installation done!

Your MQTT broker is running at :1883 or if prefered hassbian.local

To continue have a look at https://home-assistant.io/docs/mqtt/

If you have issues with this script, please say something in the #Hassbian channel on Discord.
Original script by @dale3h on gitter.im

This is because the installer did another wget to fetch the file from the mosquitto repository. It obviously isn’t intellgent enough to recognize that the file was already there.

Provided that mosquitto-stretch.list.1 and mosquitto-stretch.list files are the same, it won’t make any difference, as it will use the correct one.

This is slightly more confusing. It seems to be referring to a jessie repository. I don’t have any references to a jessie backport in my /etc/apt directory, so I have no idea where it is coming from.

Again, this is something that indicates there is something wrong the apt configuration. I haven’t seen this before, so I have no idea about it.

This is the actual problem. For some reason libssl1.0.0 isn’t being installed automatically.

Try

sudo apt-get install libssl1.0.0

To install this library manually. Its installed on my Pi, but there may be a conflict or something on your system that is preventing it.

And then run the update again. (You could rm /etc/apt/sources.list.d/mosquitto-stretch.list /etc/apt/sources.list.d/mosquitto-stretch.list.1 first, just to get rid of those errors)

so this is what I get when i try to install libssl1.0.0

pi@hassbian:~ $ sudo apt-get install libssl1.0.0
Reading package lists... Done
Building dependency tree        
Reading state information... Done
The following NEW packages will be installed:
  libssl1.0.0
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
3 not fully installed or removed.
Need to get 921 kB of archives.
After this operation, 2,010 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  libssl1.0.0
N: Ignoring file 'pwfile' in directory '/etc/apt/sources.list.d/' as it has no filename extension
N: Ignoring file 'mosquitto-stretch.list.1' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
Install these packages without verification? [y/N] y
Get:1 http://ftp.debian.org/debian jessie-backports/main armhf libssl1.0.0 armhf 1.0.2l-1~bpo8+1 [921 kB]
Fetched 921 kB in 5s (169 kB/s)       
N: Ignoring file 'pwfile' in directory '/etc/apt/sources.list.d/' as it has no filename extension
N: Ignoring file 'mosquitto-stretch.list.1' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
Preconfiguring packages ...
Selecting previously unselected package libssl1.0.0:armhf.
(Reading database ... 45929 files and directories currently installed.)
Preparing to unpack .../libssl1.0.0_1.0.2l-1~bpo8+1_armhf.deb ...
Unpacking libssl1.0.0:armhf (1.0.2l-1~bpo8+1) ...
Setting up libssl1.0.0:armhf (1.0.2l-1~bpo8+1) ...
Setting up libwebsockets3:armhf (1.2.2-1) ...
Setting up mariadb-server-10.1 (10.1.23-9+deb9u1) ...
dpkg: error processing package mariadb-server-10.1 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of default-mysql-server:
 default-mysql-server depends on mariadb-server-10.1; however:
  Package mariadb-server-10.1 is not configured yet.

dpkg: error processing package default-mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mariadb-server-10.1
 default-mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

I am concerned that this repository is being used. I am not sure how it got in to your apt set up for stretch. It may work, and the relevant files seem to have been installed, so its worth while trying for now. But future upgrades may be a problem.

The errors are regarding mariadb, which you seem to have tried to install in the past, and it still seems to have errors.

So it is worth trying to install mosquitto using the hassbian scripts again, just remove the mosquitto-stretch.list files from /etc/apt/sources.list.d/ to avoid warnings about that again.

just follow the steps