networkingmqttiotmosquitto

Mosquitto: Starting in local only mode but can't fix


My Rpi4 running my home automation recently upgraded itself from mosquitto version 1.6.12 to 2.0.8 and as a consequence it was starting in local only mode.

Done some digging about but still can't get it all working again, mainly used this previous helpful question Mosquitto: Starting in local only mode but my devices still can't connect.

From my mosquiito log I see

1614386087: mosquitto version 2.0.8 starting
1614386087: Config loaded from /etc/mosquitto/mosquitto.conf.
1614386087: Opening ipv4 listen socket on port 1883.
1614386087: Opening ipv6 listen socket on port 1883.
1614386087: mosquitto version 2.0.8 running

The service shows this

:~$ sudo systemctl status mosquitto
* mosquitto.service - Mosquitto MQTT Broker
   Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2021-02-27 00:34:47 GMT; 10h ago
     Docs: man:mosquitto.conf(5)
           man:mosquitto(8)
  Process: 375 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=exited, status=0/SUCCESS)
  Process: 398 ExecStartPre=/bin/chown mosquitto: /var/log/mosquitto (code=exited, status=0/SUCCESS)
  Process: 404 ExecStartPre=/bin/mkdir -m 740 -p /var/run/mosquitto (code=exited, status=0/SUCCESS)
  Process: 411 ExecStartPre=/bin/chown mosquitto: /var/run/mosquitto (code=exited, status=0/SUCCESS)
 Main PID: 419 (mosquitto)
   Memory: 1.5M
   CGroup: /system.slice/mosquitto.service
           `-419 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Feb 27 00:34:47 Vero4K systemd[1]: Starting Mosquitto MQTT Broker...
Feb 27 00:34:47 Vero4K mosquitto[419]: 1614386087: Loading config file /etc/mosquitto/conf.d/calz.conf
Feb 27 00:34:47 Vero4K systemd[1]: Started Mosquitto MQTT Broker.

In my calz.conf file I have

listener 1883
allow_anonymous true

But my local version of Domoticz (runs on the same box) shows this in it's logs

Error: Plugin: Connection Exception: 'resolve: Host not found (authoritative)' connecting to '127.0.0.1:1883'
Error: (ShellyMQTT) Failed to connect to: 127.0.0.1:1883, Description: resolve: Host not found (authoritative)

And all my Tasmota devices now show

14:49:38 MQT: Attempting connection...
14:49:38 MQT: Connect failed to 192.168.1.19:1883, rc -2. Retry in 120 sec

I can see the port open as well

sudo netstat -tulpn | grep LISTEN
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      361/vsftpd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      729/sshd
tcp        0      0 0.0.0.0:37015           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:36666           0.0.0.0:*               LISTEN      608/kodi.bin
tcp        0      0 0.0.0.0:36667           0.0.0.0:*               LISTEN      608/kodi.bin
tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN      375/mosquitto
tcp        0      0 0.0.0.0:49472           0.0.0.0:*               LISTEN      763/rpc.statd
tcp        0      0 0.0.0.0:9090            0.0.0.0:*               LISTEN      608/kodi.bin
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/init
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      608/kodi.bin
tcp6       0      0 :::22                   :::*                    LISTEN      729/sshd
tcp6       0      0 :::49079                :::*                    LISTEN      763/rpc.statd
tcp6       0      0 :::36666                :::*                    LISTEN      608/kodi.bin
tcp6       0      0 :::36667                :::*                    LISTEN      608/kodi.bin
tcp6       0      0 :::1883                 :::*                    LISTEN      375/mosquitto
tcp6       0      0 :::49919                :::*                    LISTEN      -
tcp6       0      0 :::9090                 :::*                    LISTEN      608/kodi.bin
tcp6       0      0 :::111                  :::*                    LISTEN      1/init
tcp6       0      0 :::8080                 :::*                    LISTEN      608/kodi.bin

/etc/mosquitto/mosquitto.conf

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/mosquitto/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

Any ideas?


Solution

  • Think I sorted it in the end, bizarre combination of things...

    Updating Mosquito required the listener port and anonymous part but for some reason my Raspberry Pi on reboot had switch across to an guest network and gained a new IP so nothing was ever going to get to it :(

    I realised when the port was listening and couldn't get to it then the same for everything else like kodi, ssh etc. I happened to be on the console for it as it was more convenient at the time, If I had tried to SSH to it that would of failed too.