So… I have never been a fan of nuke and start again but this was the only way I could get v4.1 to work. Hooray - I got there!!! Happy days!
There MUST be some artifact that exists in a prior install that stops an upgrade from v4.0 to v4.1 from working. An artifact that is NOT accessible from normal edits of the files in the config folder. I tried lots and lots of config edits - nothing worked. I even deleted my SSL certificates and re-generated them - no joy!
If you are having these same infuriating issues, I personally would recommend the following…
- Via Samba - copy all of your config files to a location other than your Hass server.
- Go to all your add-ons and copy and paste your config entries to a text file on your computer.
- Follow the Getting started instructions to begin a bare metal installation of HassIO. ie new micro-SD.
- Install the add-ons - Duck DNS, Samba share and finally the problematic Mosquitto broker. Obviously copying and pasting back your config parameters. But do NOT do this for Mosquitto broker.
- In Configuration > Users, create a Username / Password combo that matches your existing MQTT clients.
- Create the v4.1 required ACL files in your share folder as per Official Docs
- Have NO MQTT references in your configuration.yaml file.
- Go with the default Mosquitto broker config parameters ( for v4.1 which requires ACL - ie.
"active": true,
):
{
"logins": [],
"anonymous": false,
"customize": {
"active": true,
"folder": "mosquitto"
},
"certfile": "fullchain.pem",
"keyfile": "privkey.pem"
}
- Start the Add-on.
- Go to Configuration > Integrations. You will probably have a discovered MQTT reference at the top of this page. I got the dreaded “Unable to connect to broker” response from trying this one.
- Instead, go to the MQTT reference in the section below the heading Set up a new integration. This version provides the extra config parameters that are referred to in the official docs. ie. Broker IP, Broker port, Username and Password. Cross your fingers and hit Submit.
- This is where I had always failed. With a new install, it worked for me. Hope it does for you.
- Systematically start copying your original config files back to your new installation. NB. If you previously had a MQTT broker configured manually in your configuration.yaml, make sure you comment-out these references or just delete them all together before copying back to your new installation.
- Reboot.
- Make a snapshot and put the frustration behind you. Mystery continues.
Again, all of my original config files work with the new installation. The only difference being that Mosquitto broker v4.1 works now. Whereas, with the very same config on an old installation - I could NOT get my integration to connect. And I had constant socket error / disconnect errors in the log of my broker.
My new log. Very clean…
1553336177: |-- *** auth-plug: startup
1553336177: |-- ** Configured order: http
1553336177: Opening ipv4 listen socket on port 1883.
1553336177: Opening ipv6 listen socket on port 1883.
1553336177: Opening websockets listen socket on port 1884.
1553336177: |-- with_tls=false
1553336177: |-- getuser_uri=/login
1553336177: |-- superuser_uri=/superuser
1553336177: |-- aclcheck_uri=/acl
1553336177: |-- getuser_params=(null)
1553336177: |-- superuser_params=(null)
1553336177: |-- aclcheck_params=(null)
1553336177: |-- retry_count=3
1553336177: Opening ipv4 listen socket on port 8883.
1553336177: Opening ipv6 listen socket on port 8883.
1553336177: Opening websockets listen socket on port 8884.
1553336177: Warning: Mosquitto should not be run as root/administrator.
1553336178: New connection from 192.168.1.9 on port 1883.
1553336179: Socket error on client <unknown>, disconnecting.
1553336179: New connection from 192.168.1.9 on port 1883.
1553336179: |-- mosquitto_auth_unpwd_check(mqttuser)
1553336179: |-- ** checking backend http
1553336179: |-- url=http://127.0.0.1:8080/login
1553336179: |-- data=username=mqttuser&password=mqttpass&topic=&acc=-1&clientid=
[INFO] found mqttuser on Home Assistant
1553336181: New client connected from 192.168.1.9 as 40323c1e-67f4-43c9-975a-85d5b08438ae (c1, k60, u'mqttuser').
1553336181: New connection from 192.168.1.41 on port 1883.
1553336181: |-- getuser(mqttuser) AUTHENTICATED=1 by http
1553336181: |-- mosquitto_auth_unpwd_check(mqttuser)
1553336181: |-- ** checking backend http
1553336181: |-- url=http://127.0.0.1:8080/login
1553336181: |-- data=username=mqttuser&password=mqttpass&topic=&acc=-1&clientid=
[INFO] found mqttuser on Home Assistant
1553336183: |-- getuser(mqttuser) AUTHENTICATED=1 by http
1553336183: New client connected from 192.168.1.41 as sonoff_12_4568C9 (c1, k10, u'mqttuser').
1553336183: New connection from 192.168.1.39 on port 1883.
1553336183: New connection from 192.168.1.36 on port 1883.
1553336183: New connection from 192.168.1.52 on port 1883.
1553336183: New connection from 192.168.1.49 on port 1883.
1553336183: |-- mosquitto_auth_unpwd_check(mqttuser)
1553336183: |-- ** checking backend http
1553336183: |-- url=http://127.0.0.1:8080/login
1553336183: |-- data=username=mqttuser&password=mqttpass&topic=&acc=-1&clientid=
1553336183: New connection from 192.168.1.38 on port 1883.
1553336183: New connection from 192.168.1.37 on port 1883.
1553336183: New connection from 192.168.1.45 on port 1883.
1553336183: New connection from 192.168.1.46 on port 1883.
[INFO] found mqttuser on Home Assistant
1553336185: New client connected from 192.168.1.39 as sonoff_07_B02E6B (c1, k10, u'mqttuser').
1553336185: |-- getuser(mqttuser) AUTHENTICATED=1 by http
1553336185: |-- mosquitto_auth_unpwd_check(mqttuser)
1553336185: |-- ** checking backend http
1553336185: |-- url=http://127.0.0.1:8080/login
1553336185: |-- data=username=mqttuser&password=mqttpass&topic=&acc=-1&clientid=
[INFO] found mqttuser on Home Assistant
1553336186: |-- getuser(mqttuser) AUTHENTICATED=1 by http
1553336186: |-- mosquitto_auth_unpwd_check(mqttuser)
1553336186: |-- ** checking backend http
1553336186: |-- url=http://127.0.0.1:8080/login
1553336186: |-- data=username=mqttuser&password=mqttpass&topic=&acc=-1&clientid=
1553336186: New client connected from 192.168.1.36 as sonoff_03_4974A5 (c1, k10, u'mqttuser').
[INFO] found mqttuser on Home Assistant
1553336188: |-- getuser(mqttuser) AUTHENTICATED=1 by http
1553336188: New client connected from 192.168.1.52 as sonoff_02_8F40CC (c1, k10, u'mqttuser').
1553336188: |-- mosquitto_auth_unpwd_check(mqttuser)
1553336188: |-- ** checking backend http
1553336188: |-- url=http://127.0.0.1:8080/login
1553336188: |-- data=username=mqttuser&password=mqttpass&topic=&acc=-1&clientid=
[INFO] found mqttuser on Home Assistant
1553336190: |-- getuser(mqttuser) AUTHENTICATED=1 by http
1553336190: New client connected from 192.168.1.49 as sonoff_05_BEC7FC (c1, k10, u'mqttuser').
1553336190: |-- mosquitto_auth_unpwd_check(mqttuser)
1553336190: |-- ** checking backend http
1553336190: |-- url=http://127.0.0.1:8080/login
1553336190: |-- data=username=mqttuser&password=mqttpass&topic=&acc=-1&clientid=
[INFO] found mqttuser on Home Assistant
1553336192: |-- getuser(mqttuser) AUTHENTICATED=1 by http
1553336192: |-- mosquitto_auth_unpwd_check(mqttuser)
1553336192: |-- ** checking backend http
1553336192: |-- url=http://127.0.0.1:8080/login
1553336192: |-- data=username=mqttuser&password=mqttpass&topic=&acc=-1&clientid=
1553336192: New client connected from 192.168.1.38 as sonoff_01_A80FCA (c1, k10, u'mqttuser').
[INFO] found mqttuser on Home Assistant
1553336193: |-- getuser(mqttuser) AUTHENTICATED=1 by http
1553336193: |-- mosquitto_auth_unpwd_check(mqttuser)
1553336193: New client connected from 192.168.1.37 as sonoff_04_44FB37 (c1, k10, u'mqttuser').
1553336193: |-- ** checking backend http
1553336193: |-- url=http://127.0.0.1:8080/login
1553336193: |-- data=username=mqttuser&password=mqttpass&topic=&acc=-1&clientid=
[INFO] found mqttuser on Home Assistant
1553336195: |-- getuser(mqttuser) AUTHENTICATED=1 by http
1553336195: New client connected from 192.168.1.45 as sonoff_06_BEC808 (c1, k10, u'mqttuser').
1553336195: |-- mosquitto_auth_unpwd_check(mqttuser)
1553336195: |-- ** checking backend http
1553336195: |-- url=http://127.0.0.1:8080/login
1553336195: |-- data=username=mqttuser&password=mqttpass&topic=&acc=-1&clientid=
[INFO] found mqttuser on Home Assistant
1553336197: |-- getuser(mqttuser) AUTHENTICATED=1 by http
1553336197: New client connected from 192.168.1.46 as sonoff_08_BECD3D (c1, k10, u'mqttuser').