Working rhough SMART HOME with Raspberry Pi, ESP32, and ESP8266 page 107 after successfully entering usename andpassword and modifyiying the conf file andrestarting I still get a connection refused error. I also note that sudo systemctl status mosquitto
command gives a status of:
Active: active (exited) not running as per your book.
Hi.
Did you follow the instructions shown in the eBook, or did you already have another mosquitto installation?
Try to rerun the following command:
sudo systemctl restart mosquitto
Then, reboot your raspberry pi
sudo reboot
Then, check the status of mosquitto again after the RPi restarts.
sudo systemctl status mosquitto
Let me know the results.
Regards,
Sara
No change after following your instruction.
pi@raspberrypi:~ $ sudo systemctl status mosquitto
● mosquitto.service – LSB: mosquitto MQTT v3.1 message broker
Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
Active: active (exited) since Tue 2022-09-27 20:22:58 AEST; 1min 31s ago
Docs: man:systemd-sysv-generator(8)
Process: 318 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCC
Tasks: 0 (limit: 4915)
CGroup: /system.slice/mosquitto.service
Sep 27 20:22:57 raspberrypi systemd[1]: Starting LSB: mosquitto MQTT v3.1 messag
Sep 27 20:22:58 raspberrypi mosquitto[318]: Starting network daemon:: mosquitto.
Sep 27 20:22:58 raspberrypi systemd[1]: Started LSB: mosquitto MQTT v3.1 message
lines 1-11/11 (END)
I have followed the steps in your book apart from the actual pi install. I had one allready set up and readyto go. This did not include mosquitto however.
I examined the password file with nano and it showed the usernames I had put corectly. Passsowrd was scrambled as expected.
Broker responded correctly without authentication but after authentication is added I get this.
mosquitto_pub -d -t testTopic -m “Hello world!” -u mal -P mal
Error: Connection refused
this is my conf file
# 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
per_listener_settings true
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
allow_anonymous false
listener 1883
password_file /etc/mosquitto/passwd
Thank you for your help.
Hi.
I’m not sure why you’re getting that issue.
Did you start a new installation of the OS when you started the eBook? Did you install the mosquito from start or did you already have mosquito installed? I’m trying to understand what might be the cause.
I found a similar issue: https://github.com/eclipse/mosquitto/issues/641
They mention that if you set the persistence setting to false instead of true in the configuration file, it solves the problem:
persistence false
Let me know if this helps with your issue.
Regards,
Sara
Try only this if the previous workaround doesn’t work.
Also, try changing the following line:
pid_file /var/run/mosquitto.pid
To
pid_file /run/mosquitto/mosquitto.pid
Regards,
Sara
Thanks for your time Sara.
Tried all the above but no joy so I blew away the old installation and restrated from scratch with a fresh install everything is now OK and status now says running and not exited. Authenticated messages now working
Thanks again
Mal