Page 1 of 1

problems with mqtt

Posted: Friday 16 December 2022 19:31
by JuanUil
Hi all,

since yesterday I have a big problem with mosquitto mqqt.

The broker doesn't want to connect anymore.
In domoticz log I get:

Code: Select all

2022-12-16 19:25:24.839 Status: MQTT: Worker stopped...
2022-12-16 19:25:25.851 Status: MQTT: Connecting to 192.168.2.21:1883
2022-12-16 19:25:25.851 Error: MQTT: Failed to start, return code: 14/Connection refused (Check IP/Port)
when i ssh and give the command systemctl status mosquitto.service I get:

Code: Select all

systemctl status mosquitto.service
* mosquitto.service - Mosquitto MQTT Broker
     Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Fri 2022-12-16 19:27:19 CET; 1min 45s ago
       Docs: man:mosquitto.conf(5)
             man:mosquitto(8)
    Process: 2792 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=exited, status=0/SUCCESS)
    Process: 2793 ExecStartPre=/bin/chown mosquitto /var/log/mosquitto (code=exited, status=0/SUCCESS)
    Process: 2794 ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto (code=exited, status=0/SUCCESS)
    Process: 2795 ExecStartPre=/bin/chown mosquitto /run/mosquitto (code=exited, status=0/SUCCESS)
    Process: 2796 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
   Main PID: 2796 (code=exited, status=1/FAILURE)
        CPU: 95ms

dec 16 19:27:19 PI4Nieuw systemd[1]: mosquitto.service: Failed with result 'exit-code'.
dec 16 19:27:19 PI4Nieuw systemd[1]: Failed to start Mosquitto MQTT Broker.
dec 16 19:27:19 PI4Nieuw systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 5.
dec 16 19:27:19 PI4Nieuw systemd[1]: Stopped Mosquitto MQTT Broker.
dec 16 19:27:19 PI4Nieuw systemd[1]: mosquitto.service: Start request repeated too quickly.
dec 16 19:27:19 PI4Nieuw systemd[1]: mosquitto.service: Failed with result 'exit-code'.
dec 16 19:27:19 PI4Nieuw systemd[1]: Failed to start Mosquitto MQTT Broker.
in /etc/mosquitto/mosquitto.conf I have:

Code: Select all

# 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 /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
listener 1883
allow_anonymous true
strange is also that the problem is coming back even if i use a backup image of a working system!!

some more info:

Code: Select all

pi@server5:~ $ mosquitto -v
1671219391: mosquitto version 2.0.11 starting
1671219391: Using default config.
1671219391: Starting in local only mode. Connections will only be possible from clients running on this machine.
1671219391: Create a configuration file which defines a listener to allow remote access.
1671219391: For more details see https://mosquitto.org/documentation/authentication-methods/
1671219391: Opening ipv4 listen socket on port 1883.
1671219391: Error: Address already in use
1671219391: Opening ipv6 listen socket on port 1883.
1671219391: Error: Address already in use
Any help is highly appreciated!!!

Jan

Re: problems with mqtt

Posted: Friday 16 December 2022 23:30
by ferrosk
these messages:

1671219391: Opening ipv4 listen socket on port 1883.
1671219391: Error: Address already in use
1671219391: Opening ipv6 listen socket on port 1883.
1671219391: Error: Address already in use

means that some other service is already using port 1883 on your system so mosquitto cannot bind to this port and fails to start... Try find which process is using the port by:

Code: Select all

sudo netstat -anp | grep 1883

Re: problems with mqtt

Posted: Saturday 17 December 2022 15:34
by JuanUil
Thnx ferrosk for your advice,

made a complete new install and everything working again.

greetz
Jan

Re: problems with mqtt

Posted: Sunday 18 December 2022 10:34
by gizmocuz
Try using docker compose