mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

Stopped working on Pi when running via systemctl

Open TotallyInformation opened this issue 7 years ago • 10 comments

I've just updated my Pi which is running Rasbian Jesse. I guess I got v1.5 at that point.

However, I now always get the following error when booting the Pi:

[Sun May 20 10:56:19 2018]: mosquitto version 1.5 starting
[Sun May 20 10:56:19 2018]: Config loaded from /etc/mosquitto/mosquitto.conf.
[Sun May 20 10:56:19 2018]: Opening ipv4 listen socket on port 1883.
[Sun May 20 10:56:19 2018]: Opening ipv6 listen socket on port 1883.
[Sun May 20 10:56:19 2018]: Opening websockets listen socket on port 9001.
[Sun May 20 10:56:19 2018]: Opening ipv4 listen socket on port 1883.
[Sun May 20 10:56:19 2018]: Error: Address already in use

As you can see, it appears to be trying to open twice. The result is that no connections are possible.

I removed Mosquitto and reinstalled after manually deleting /etc/mosquitto and weirdly, I still get the same problem even though I now have no config file at all.

When I run it manually from the command line, everything works as expected. Importantly, running without a config file means that I don't get websockets on port 9001 which is what I expect so I can't work out what is causing that configuration to still be active when running via systemctl.

Confused!! Can anyone help? Thanks.

TotallyInformation avatar May 20 '18 12:05 TotallyInformation

Hi, I have this problem too! Thanks for posting

jorgebnunes avatar May 20 '18 13:05 jorgebnunes

It looks as though a default has changed. Previously, I specified the settings for the standard listener in my local config file. Now, when that happen, it tries to reopen the default listener. If I disable the local config, it works.

/etc/mosquitto/mosquitto.conf

pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d

/etc/mosquitto/conf.d/pi.conf

# Standard Listener
listener 1883
protocol mqtt
log_type error
log_type warning
log_type notice
log_type information

# Websockets Listener
listener 9001
protocol websockets

As a work around, comment out the listener 1883 section.

I think this is going to cause issues for people.

TotallyInformation avatar May 20 '18 13:05 TotallyInformation

Thanks man! This fixes it for now.

jorgebnunes avatar May 20 '18 13:05 jorgebnunes

I've got the same problem while updating my Armbian Jessie server; it was trying to open another server at 1883. Commenting out the listener as mentioned by @TotallyInformation works

Unfortunately that's not the only problem I had. I had the following other issues after the update:

  • Node-red instance was getting disconnected over socket errors -- Purging mosquitto and installing again seemed to have fixed it.
  • esp8266 with Homie cannot properly connect to broker, and keeps getting disconnected.
  • Web page using mqttws31.js and websocket connects to broker, but does not receive any messages. (it looks like it keeps receiving the onConnect event constantly)

guibom avatar May 21 '18 06:05 guibom

In mosquitto 1.5 on a Pi, I don´t specify a listener on port 1883 in my config (since I instead configure WS, WSS, and TLS).

in version 1.4.15 this worked as expected in version 1.5 there are now listeners launched on port 1883 (and I don’t know how to turn them “off”)

1527190660: Opening ipv4 listen socket on port 1883.
1527190660: Opening ipv6 listen socket on port 1883.

So it appears that, as theorized above, some default settings got changed, that auto-specify a standard MQTT port listener... Should a separate issue be filed, or is this existing one good enough?

idcrook avatar May 24 '18 19:05 idcrook

I also have this problem, as a result of the update I have problems between my raspberry and arduinos (esp8266 and mega).

Is there any way to remove it and go back to the previous version?

Can someone describe how to install a specific version manually?

regards

valdragas avatar May 25 '18 06:05 valdragas

I had the same trouble. It also seems to me that a default listener on 1883 tcp port (ipv4 and ipv6) is always started, even if we have defined the same listener on 1883 already, or other default listener on another port. It would be great if mosquitto could check if a default listener was already set, so it would not try to setup the same twice, otherwise we cannot disable the default listener on 1883.

DarkCompiled avatar Sep 07 '18 09:09 DarkCompiled

I was stuck on the same problem. But the docs say:

port port number Set the network port for the default listener to listen on. Defaults to 1883.

So it looks like there will always be this default port for the default listener. But you can change it or only allow localhost on it.

And with the help of google groups:

# default listener only on localhost
bind_address localhost # or 127.0.0.1

port 1883 # default port, could be omitted or changed to another port.

# TLS listener
listener 8883
...

So as @TotallyInformation wrote: commenting out listener 1883 is not only a work around but the solution. First the config for the default listener (listener 1883), after that config for other listeners.

illnr avatar Apr 19 '19 17:04 illnr

This should have been fixed in version 1.5.1. @iBaff , could you check which version you were using?

ralight avatar Apr 25 '19 12:04 ralight

I've just updated my Pi which is running Rasbian Jesse. I guess I got v1.5 at that point.

However, I now always get the following error when booting the Pi:

[Sun May 20 10:56:19 2018]: mosquitto version 1.5 starting
[Sun May 20 10:56:19 2018]: Config loaded from /etc/mosquitto/mosquitto.conf.
[Sun May 20 10:56:19 2018]: Opening ipv4 listen socket on port 1883.
[Sun May 20 10:56:19 2018]: Opening ipv6 listen socket on port 1883.
[Sun May 20 10:56:19 2018]: Opening websockets listen socket on port 9001.
[Sun May 20 10:56:19 2018]: Opening ipv4 listen socket on port 1883.
[Sun May 20 10:56:19 2018]: Error: Address already in use

As you can see, it appears to be trying to open twice. The result is that no connections are possible.

I removed Mosquitto and reinstalled after manually deleting /etc/mosquitto and weirdly, I still get the same problem even though I now have no config file at all.

When I run it manually from the command line, everything works as expected. Importantly, running without a config file means that I don't get websockets on port 9001 which is what I expect so I can't work out what is causing that configuration to still be active when running via systemctl.

Confused!! Can anyone help? Thanks.

to solve this problem you need terminate mosquitto that maybe you suspend only. To terminate mosquitto you should open activity monitor and find mosquitto among processes in the disk. finally you should doing double click on mosquitto(among processes) and click on exit. In alternative you can write fg in your terminal for resume mosquitto process and teminate it with ctr+c.

Omni-star avatar Jun 03 '22 16:06 Omni-star