Mosquitto MQTT 4.1 doesnt work after update

Tags: #<Tag:0x00007f7c5dc477b0>

I have a few ESP8266’s programmed for mqtt and they all connect without username and password.
It would be a big hassle to take all these devices out of they housing, solder wires to them and re-program them.

Still i think when anonymous =true the broker should connect without user and pass.

I roll back to my separate mqtt broker and maybe some time when this bug is resolved i come back.

Tnx for your help so far David.

So not running Tasmota? Because if Tasmota you can just set username/password via the web GUI.

Not on all devices…

Try adding:

allow_anonymous true

To the acl file.

Gives an error:

[09:51:01] INFO: Setup mosquitto configuration
[09:51:01] WARNING: SSL not enabled - No valid certs found!
[09:51:03] INFO: No local user available
[09:51:04] INFO: Initialize Hass.io Add-on services
[09:51:04] INFO: Initialize Home Assistant discovery
[09:51:04] INFO: Start Mosquitto daemon
1569916264: Loading config file /share/mosquitto/._acl.conf
1569916264: Loading config file /share/mosquitto/acl.conf
1569916264: mosquitto version 1.6.3 starting
1569916264: Config loaded from /etc/mosquitto.conf.
1569916264: Loading plugin: /usr/share/mosquitto/auth-plug.so
1569916264: |-- *** auth-plug: startup
1569916264:  ├── Username/password checking enabled.
1569916264:  ├── TLS-PSK checking enabled.
1569916264:  └── Extended authentication not enabled.
1569916264: Error: Invalid line in acl_file "/share/mosquitto/accesscontrollist": allow_anonymous.
1569916264: Error opening acl file "/share/mosquitto/accesscontrollist".

This option is true by default

It’s only true by default if nothing else is specified in the ACL file according to my reading.

I lost two of my devices after the .102.3 update and am re-reading all of the setups. I get the following error in both of the devices that no longer work: MQT: Connect failed to 192.168.1.48:1883, rc -2. Retry in 10 sec.
I am now confused on the setup. My old configuration for mqtt:

{
  "logins": [
    {
      "username": "hassio",
      "password": "myhassio"
    }
  ],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_certificate": false
}

I deleted the MQTT and the integration.
I then added it with the config above. I then added a user name. Should the user name match the user name in the MQTT configuration? If not, what is this username for? I had created a user called MQTT but was uncertain what to do with it. I always used the username and password that is in the config when I setup my devices.
Hopefully you can add so input so I can understand how to fix this issue.
Thanks.

    {
      "username": "hassio",
      "password": "myhassio"
    }

So that part defines a LOCAL MQTT user. You should just create the same user in Home Assistant and leave that at the defaults in the addon.
Then on the devices, use that same user/pass for the MQTT logon.

Thanks. Wasn’t clear in the documents. I think a lot has changed in HA after the documentation were released. My user never matched the config user. I’m going to uninstall, mqtt, integration and the user and then resonate all with them matching. I’ll let you know.

Reinstalled again. Created user and used the user in the MQTT setup. Now only two devices connecting out of 5. Same RC2 error.

Tried many installs, reinstalls and no luck. The RC -2 error has to do with connection refused, identifier rejected. The client identifier is correct UTF-8 fut not allowed by server. This to me points to an error in HA as it is the server. Maybe something is corrupted HA? I would think uninstalling, rebooting would remove it. Do you know where HA stores it’s MQTT infor? Any ideas to try? In doing searches, it looks like this is not an uncommon problem, but I have not seen anyone explaining the root cause and how to resolve it.
Thanks.

If you uninstall the addon it removes the persistence database and settings.

You didn’t say what kind of devices you are using.

My broker is configured like this:

{
  "logins": [],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_certificate": false,
  "quiet_logs": true
}

See no login so it uses a HA user to authenticate:
image
I created a Home Assistant user MQTT-User and I use that username and password in all my devices to authenticate.

IF you are using something other than that kind of setup that may be your problem. It could also be that you need to setup an accesscontrol list and acl.conf file but you shouldn’t need that.

I created a user called mqtt. My configuration is:

  "logins": [
    {
      "username": "mqtt",
      "password": "myhassio"
    }
  ],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_certificate": false
}

The sonoff devices with Tasmota flashed use the username mqtt and password myhassio. Is this incorrect? From the error message -rc2 on the two devices that failed, it doesn’t seem like it is a password issue?

remove the user from the addon!!! as I showed you above.
I’m confused… do you have more than 2 devices and some are working? If so then I’d check to make sure you don’t have spaces etc in the IP address on the ones that are failing and that you have entered the user/pass correctly.

I have 5 devices. 2 were not working. I just changed a wifi settings on one and it is back in HA. I have a mesh setup and for some strange reason it was connecting to a distant node instead of the node next to it.
Most of the new directions I found on setting up the MQTT addon said to change the mqtt setup and add the username and password for the add on. Not sure if you are correct or they are correct? A lot of confusion on this as there have been many changes in HA and the documentation has not caught up. Your answer makes sense as that would be why the user is created. Looks like it should be one or the other, not both as I have it. It is working as I have it now. I will go back to the default removing both the password and username and see if any issues are created.

The password, user and setup is what I have used for months with no issues. My RC-2 error and finding out what it meant made me believe it was caused by a bad HA setup. I now after getting one more to go on line believe it had to do with a low wifi level causing an internet connection issue.

I will do some testing tomorrow and see if the problem is also caused by a low wifi level. I may be on the edge of the range. I’ll do some testing and if necessary move it tomorrow and see if the issues go away.
I’ll let you know.

Thanks for your help.

Thats not how I read the docs.

digiblurDIY has a new video on youtube showing to use username and password.

https://www.youtube.com/watch?v=KOg5qwO3Rh4&feature=youtu.be

'''
I could not find easily others but there are many, maybe all wrong that say to setup a user, than username and password.
Looks like it is not necessary
By the way, moved the sonoff closer and all of my devices are back.  
Thanks for your help.

and? the official docs are what you should be using!

I changed it to like you said and it is still working. I did go back to the doc and the mqtt docs

 https://www.home-assistant.io/addons/mosquitto/

Calls out the username and password. The add in does not. I thought I was using the official docs. My confusion, sorry.

Hey all good mate. Videos get old fast and even Digiblur isn’t necessarily up with the latest stuff. It’s actually been a few releases since you didn’t need to specify a local user. Glad you worked out it was WiFi anyway…