0

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?

Calzor Suzay
  • 53
  • 4
  • 9
  • `resolve: Host not found` means it can't convert '127.0.0.1:1883' to a host name, this most likely means that you should NOT have included the port number – hardillb Feb 27 '21 at 14:16
  • Use the earlier version 1.6 in a docker container. – Sun Bee Dec 26 '21 at 14:35

2 Answers2

0

Your problem is not that Mosquitto is not listening, it's that your devices are trying to resolve a hostname of 127.0.0.1:1883

I suspect you have entered the host:port combination into fields that should

  1. Only contain a hostname/IP address
  2. You probably should NOT be entering 127.0.0.1 as this always points to the device it is entered on and you should be entering the IP address the broker is actually running on.
hardillb
  • 54,545
  • 11
  • 67
  • 105
  • No the 127.0.0.1 log is where MQTT is running so Mosquitto and Domoticz are on the same device so localhost should work. I've fixed the bad copy/paste for the external devices, these point to 192.168.19 where the Rpi4 is. So neither local or external works. – Calzor Suzay Feb 27 '21 at 13:50
  • Fine, but you probably shouldn't be including port number in the host field – hardillb Feb 27 '21 at 13:53
  • Just tried from another Windows box using a port query ``` Starting portqry.exe -n 192.168.1.19 -e 1883 -p TCP ... Querying target system called: 192.168.1.19 Attempting to resolve IP address to a name... Failed to resolve IP address to name querying... TCP port 1883 (unknown service): NOT LISTENING portqry.exe -n 192.168.1.19 -e 1883 -p TCP exits with return code 0x00000001. ``` – Calzor Suzay Feb 27 '21 at 13:57
  • Sorry what do you mean by the "port number in the host field", the only place I'm specifying a port is in the calz.conf file under listener. – Calzor Suzay Feb 27 '21 at 13:59
  • Edit the question to show 1) /etc/mosquittto/mosquitto.con 2) the output of `sudo lsof -i -P | grep mosquitto` – hardillb Feb 27 '21 at 14:12
  • /etc/mosquittto/mosquitto.con file not found and I don't have lsof installed it seems so included netstat – Calzor Suzay Feb 27 '21 at 14:20
-1

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.

Calzor Suzay
  • 53
  • 4
  • 9