Page 1 of 1
MQTT connection failed rc -2
Posted: Tuesday 11 October 2022 20:00
by Rolandet
Hi all,
I've spent some time going through the search, so forgive me if there's already a topic for this error (and hopefully with a solution)
If not, then I hope you can help me out:
Recently installed new SD card (old one FUBAR). Installed Domoticz etc and mqtt per Jelle Peters' youtube vid
- Spoiler: show
- https://www.youtube.com/watch?v=w7QhsFqBr30&t=7s
. as I have done many times before (be it a long time ago)
Now the problem I have is that my LSC smart plugs (flashed to tasmota) can not connect to the broker
Code: Select all
Connect failed to 192.168.178.24:1883, rc -2.
I've gone over several topics, about adding/removing
Code: Select all
listener 1883 allow_anonymous true
. etc but I just can not get it to work
Anyone here have the golden hint, or is willing to help me debug?
I realise I may have to add some more settings here, in order to troubleshoot. Please ask, and I'll add it a.s.a.p
tnx
Roland
Re: MQTT connection failed rc -2
Posted: Tuesday 11 October 2022 21:10
by ferrosk
Hi,
By default mosquitto is running in local mode only (listening for connection on localhost interface so it is reachable only by clients running on the same host as mosquitto is running). You need to enable mosquitto to listen on your network (lan) interfaces - add this to conf:
listener 1883 0.0.0.0
but be aware that with this together with "allow_anonymous true" option you authorize connection to mosquitto from all hosts on your network without authentication so it is unsecure!
Re: MQTT connection failed rc -2
Posted: Tuesday 11 October 2022 21:35
by Rolandet
Tnx ferrosk
I'm curious, is this a new feature/setting?
Cause I've used a quite old way of setting things up (hence the reference to the YouTube vid)
Re: MQTT connection failed rc -2
Posted: Tuesday 11 October 2022 21:48
by ferrosk
Re: MQTT connection failed rc -2
Posted: Tuesday 11 October 2022 21:57
by Rolandet
I see. That would explain why my old rpi4 installation (mosquito v1.5.7) doesn't have this issue (to be fair, this topic is about another users setup)
Re: MQTT connection failed rc -2
Posted: Thursday 13 October 2022 18:27
by Rolandet
ferrosk wrote: Tuesday 11 October 2022 21:10
Hi,
By default mosquitto is running in local mode only (listening for connection on localhost interface so it is reachable only by clients running on the same host as mosquitto is running). You need to enable mosquitto to listen on your network (lan) interfaces - add this to conf:
listener 1883 0.0.0.0
but be aware that with this together with "allow_anonymous true" option you authorize connection to mosquitto from all hosts on your network without authentication so it is unsecure!
I've gotten a little further thanks to your suggestion.
In /var/log/mosquitto/mosquitto.log I see:
Code: Select all
Config loaded from /etc/mosquitto/mosquitto.conf
But the device still shows the same error, like mosquitto hasn't properly read the conf file
After a reboot I see the process running:
Im not sure, but it looks like that would suggest the conf file is not read.
When I kill this process and restart it using
sudo systemctl start mosquitto the new PID shows:
Code: Select all
PID 5825 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Now it DOES allow my device to connect (and indeed I can control it from Domoticz)
So somehow the start of mosquitto after reboot doesn't seem to load the conf file
Where can I see what parameters are passed when a program is started automatically after boot?