Configuration de Mosquitto

Skip to first unread message


Aug 23, 2021, 1:09:43 PM8/23/21

I am far from being a network specialist, but I learn a little bit at a time.
My goal is to dialog with Arduino in MQTT via Mosquitto installed on a Raspberry.
But if it works in localhost, this is not the case in the local network. I do not know how to connect, and I do not understand the Mosquitto configuration options.
thanks in advance !

The default configuration:

# 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.gz

pid_file /run/mosquitto/

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

Aug 23, 2021, 4:45:45 PM8/23/21
It is not clear from your question whether your setup works when set to localhost. If it does work, then change the connection from localhost to the IP address of the Pi and other devices too.


Aug 25, 2021, 11:24:24 AM8/25/21
Sorry, the answer was placed in spam and I only come to see.

Yes, it works well in localhost, but not with "MQTT Explorer" under Windows or sketches of connection in Arduino.
No way connect to the server. I disabled the firewall of the Asus RT-AC88U router and I do my ethernet tests.
I installed it on another PI "virgin" and I have the same problem.

2021.08.25 16.330001 PC-POLLUX.png
2021.08.25 16.480002 PC-POLLUX.png

It's been a week that I turn around and a lot of tutorials seem to copy one over the other but without examples or explanations.
Not to mention that I do not master English and that translators are sometimes approximate in the technical fields

Un grand merci d'avance !

Aug 26, 2021, 1:11:50 AM8/26/21
I did an install of the Mosquitto broker on my Mac with the default mosquitto.conf file. After launching, the dialog in the terminal stated that the broker was "Starting in local only mode. Connections will only be possible from clients running on this machine." 
So, going back to your original query, you stated that "it worked on localhost". This implies that you had installed Mosquitto on the Pi and you were running a client (publisher or subscriber) on the same machine. Correct? 
Research how to configure Mosquitto to make sure an IP address is being properly exposed. Clearly, you understand the network requirement since you have an IP address in MQTT Explorer. 
Note that you should set a static IP address for the Pi so that it does not change between reboots. You can configure the DHCP server in your router to assign an IP to the Pi's MAC addr (reboot router).

j'espère que j'ai aidé (blame Google translate if that does not make sense!)


Aug 26, 2021, 4:09:15 AM8/26/21
« J'espère que j'ai aidé (blame Google translate if that does not make sense!)  »  Oui merci !

No problem for my IP addresses, static on both sides.
We say that the night brings counsel. I consulted the log, and there ....

sudo tail -f /var/log/mosquitto/mosquitto.log | tee /var/tmp/mosquitto.log
1629960276: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.
1629960276: mosquitto version 2.0.11 starting
1629960276: Config loaded from /etc/mosquitto/mosquitto.conf.
1629960276: Starting in local only mode. Connections will only be possible from clients running on this machine.
1629960276: Create a configuration file which defines a listener to allow remote access.

1629960276: For more details see
1629960276: Opening ipv4 listen socket on port 1883.
1629960276: Opening ipv6 listen socket on port 1883.
1629960276: mosquitto version 2.0.11 running
1629962076: Saving in-memory database to /var/lib/mosquitto//mosquitto.db.

The page is much clearer than all the tutorials I've read, especially for the addition of passwords and even without translator;)
She is in my favorites.
However, I first wanted to try without password.
After several trial and error, I added these 3 lines in the configuration file

allow_anonymous true
listener 1883
protocol mqtt

That's it, I hope TOPIC will help others!
And a special thank you to you, d ... @ I sense that you have more of humor!


Aug 26, 2021, 10:09:48 AM8/26/21
Le Forum Mosquitto m'a enfin répondu :

« From Mosquitto version 2.0 onwards some of the way the broker works changed, which is why the tutorials you are looking at may miss some steps out I imagine.

If you run Mosquitto without a configuration file then it will allow unauthenticated access but on localhost only. The same is true if you have a configuration file but do not define a listener.

If you want to allow connections from other computers, you must define a listener and define some form of authentication. That could be password file based authentication, the dynamic security plugin, or allowing unauthenticated access with the allow_anonymous true option. »

etc. Dont acte !

Reply all
Reply to author
0 new messages