Im trying to use the MQTT broker on my emonpi but am having trouble connecting. I can connect using the default credentials (emonpi emonpimqtt2016) but nothing else.
I’ve tried adding users and passwords to the correct password file but they get ‘not authorised’ messages when they try to connect and I’ve tried setting allow anonymous to True in the config but still, the only connection that can be made is the one using the default credentials.
I’m wanting to connect several arduino devices to the broker and assume (possibly incorrectly) that if all of them log in with the same credentials, something is going to go wrong somewhere…
Anyone know how I can
A) allow other users or even anonymous connections to the broker
B) configure it so that I don’t have to create a new user for each new device I want to connect to the broker
There were 4 users in there, Pi, Emonpi, user1, user2. Each with their own encrypted password
I exited nano without making any changes. All 4 of those user could at this point connect to MQTT broker (don’t ask how I got these in there, I honestly don’t know).
setup a password and tried to connect but got a not authorised response.
So I used nano to look at the file again and the only user in there was the new garage one! Which couldn’t connect.
I then tried the other users that used to be in the password file. All the ones I had created no longer worked but the default emonpi emonmqtt2016 combination still did?!
Safe to say, I’m pretty confused by the whole thing
I should add that I have just remembered how I added the other users; I ran your line of code without the -c to prevent it creating a new file and overriding the old one.
So I have now done this three times and created 3 users in the passwd file, which I can see when I use nano, each with its own encrypted password
But still, the only one that can connect is the default user?!
If you want to add new users, use the same command but without the -c so it doesn’t create a new file each time.
Once you have added all the new users you want to, you need to restart the Mosquitto service for it to pickup the changes.
sudo mosquitto service stop
sudo mosquitto service start
When I did this, all the added users started working. No clue why the default user was connecting when it wasn’t in the passwd file, but hey, it was working so thats what matters.