• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

mosquitto.service Active:failed

Q&A Forum › Category: Raspberry Pi › mosquitto.service Active:failed
0 Vote Up Vote Down
Joe Margevicius asked 2 years ago

Hi Sara,  I am going through the eBook Smart Home RPi & ESP32 and am stuck at the Mosquitto install/test section.  I installed it and did the test with 2 terminals, and got the proper results. Then I implemented the security feature (i.e. user and password), and found I could still do the test (it didn’t complain about errors).  Then I did something – I don’t know what – and then couldn’t get mosquitto to restart.  So, as per another blogger’s question/answer, I removed mosquitto (i.e. sudo apt remove mosquitto mosquitto-clients), and afterwards get -bash: mosquitto: command not found, which is what one would expect.  Then I reinstalled (i.e. sudo apt install – y mosquitto mosquitto-clients), and did sudo systemctl enable mosquitto.service, then tried mosquitto -v and get
 
1672954368: mosquitto version 1.5.7 starting
1672954368: Using default config.
1672954368: Opening ipv4 listen socket on port 1883.
1672954368: Opening ipv6 listen socket on port 1883.
 
(it hangs there, then eventually states ^C1672954471: mosquitto version 1.5.7 terminating).
 
When I open another terminal, and do mosquitto_sub -d -t testTopic, I get: Error: Connection refused
 
I tried sudo reboot, and again the mosquitto_sub -d -t testTopic … with the same result.  Trying sudo systemctl enable mosquitto.service then the mosquitto_sub -d -t testTopic …. again Error: Connection refused
 
Any idea why I can’t do the test again ?  … I deleted the password file, and removed any new stuff in the .config file – doesn’t help.  Thanks for any advice.  — JoeM

Question Tags: mosquitto
3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
I’m not sure what might be the issue.
How does you configuration file look like?
Regards,
Sara

0 Vote Up Vote Down
Joe Margevicius answered 2 years ago

Hi Sara … I figured it out.  The bottom line is that the allow_anonymous false statement causes the connection error.  When I commented that out, it worked fine, including requiring the username/password to do the testTopic.

I also had another issue:  there was a mosquitto.conf file in /etc/mosquitto/conf.d directory which is not purged (or removed) by the sudo apt remove mosquitto command, and even though I removed all the “extra stuff” the eBook states for when authentication is implemented,  the /etc/mosquitto/mosquitto.conf file states that things can be found in the /etc/mosquitto/conf.d directory (which still had the modified mosquitto.conf file).

Anyway. I’m not perfectly clear why the allow_anonymous false statement causes the connection error… the man pages for mosquitto.conf state the following:

allow_anonymous [ true | false ]
Boolean value that determines whether clients that connect without providing a username are allowed to connect.
If set to false then another means of connection should be created to control authenticated client access.
Defaults to true if no other security options are set.
If any other authentication options are set, then allow_anonymous defaults to false.

“Boolean value that determines whether clients that connect without providing a username are allowed to connect” would seem to imply making it false when a password file is present ….

Anyway, all is well now.  this can be closed

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Ok.
Great.
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.