OpenEnergyMonitor Community

Install causing MQTT problems

I recently started again from fresh with a brand new install of Emoncms on a Pi4 8GB booting from SSD and it’s taken me an age to work out why MQTT on some devices stopped working. It turns out the Emoncms installation sets up authentication on the MQTT server and even when anonymous connections are allowed the presence of ‘password_file /etc/mosquitto/passwd’ in mosquitto.conf stops clients who send any username (including null string) from connecting. This causes issues with for example the Arduino PubSubClient when trying to set Last Will. I don’t need MQTT authentication here because it’s all LAN side and as the user and password are hard coded in Emoncms it’s hardly secure anyway. Maybe there should be a choice whether to have MQTT security when installing ?

Hello @Bra1n, Perhaps a note somewhere in the documentation on how to disable MQTT authentication would be useful? What steps did you take to get it working?

edit /etc/mosquitto/mosquitto.conf

Adding a new line with allow_anonymous true allows connections without username and password but clients that do send a username and/or password need to have a match in the password file.

Clients which send a null value (empty string) for the username parameter (such as the arduino pub/sub client) won’t find a match in the password file so for these clients to connect anonymously they need to have the password_file line commented out or deleting e.g. #password_file /etc/mosquitto/passwd