Mosquitto MQTT 4.1 doesnt work after update

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…

I tried to follow this thread with good care, but I still couldn’t figure out did someone actually managed to get the anonymous connections to work and with what kind of setup?