I am running Home Assistant (HASSOS) running in a Ubuntu VMWare VM.
I just installed the Mosquitto Broker addon with the below configuration:
logins: - username: mkanet password: 'mypassw#rd' anonymous: false customize: active: false folder: mosquitto certfile: fullchain.pem keyfile: privkey.pem require_certificate: false
I currently have an MQTT client connecting to this broker; pointing it to: 192.168.1.2 with the same username and password specified in the above configuration.
If I reboot Home Assistant, my client (IOTLink), keeps trying to connect/disconnect over and over again, unless I restart the IOTLink service 3 times. The log for this client looks like below over and over again (unless I restart the IOTLink service 3 times). The 4th time, IOTLink finally connects.
[MKANET\HORIZON][2020-05-23 21:41:54 -07:00][SYSTEM][IOTLinkService.Service.MQTT.MQTTClient]: ALL YOUR MQTT TOPICS WILL START WITH iotlink/MKANET/horizon/ [MKANET\HORIZON][2020-05-23 21:41:54 -07:00][WARNING][IOTLinkService.Service.MQTT.MQTTClientManager]: MQTTClientManager::VerifyConnection() - MQTT Connection Broken. Reconnecting. [MKANET\HORIZON][2020-05-23 21:41:54 -07:00][INFO][IOTLinkService.Service.MQTT.MQTTClient]: MQTTClient::Disconnect() - Trying to disconnect from broker: tcp://192.168.1.7:1883. [MKANET\HORIZON][2020-05-23 21:42:02 -07:00][INFO][IOTLinkService.Service.MQTT.MQTTClient]: MQTTClient::OnConnectedHandler() - MQTT Connected
The respective MQTT Broker log looks like below after I reboot HA:
[21:41:59] INFO: Setup mosquitto configuration [21:41:59] WARNING: SSL not enabled - No valid certs found! [21:41:59] INFO: Found local users inside config [21:42:00] INFO: Initialize Hass.io Add-on services [21:42:00] INFO: Initialize Home Assistant discovery [21:42:00] INFO: Start Mosquitto daemon 1590295320: mosquitto version 1.6.3 starting 1590295320: Config loaded from /etc/mosquitto.conf. 1590295320: Loading plugin: /usr/share/mosquitto/auth-plug.so 1590295320: |-- *** auth-plug: startup 1590295320: ├── Username/password checking enabled. 1590295320: ├── TLS-PSK checking enabled. 1590295320: └── Extended authentication not enabled. 1590295320: Opening ipv4 listen socket on port 1883. 1590295320: Opening ipv6 listen socket on port 1883. 1590295320: Opening websockets listen socket on port 1884. 1590295321: Warning: Mosquitto should not be run as root/administrator. 1590295321: New connection from 192.168.1.2 on port 1883. [INFO] found mkanet on local database 1590295322: New client connected from 192.168.1.2 as horizon (p2, c1, k60, u'mkanet'). 1590295322: Client horizon disconnected. 1590295322: New connection from 192.168.1.2 on port 1883. 1590295322: New client connected from 192.168.1.2 as horizon (p2, c1, k60, u'mkanet'). 1590295327: New connection from 192.168.1.2 on port 1883. 1590295328: New client connected from 192.168.1.2 as 84525947701 (p2, c1, k60, u'mkanet'). 1590295381: New connection from 172.30.32.1 on port 1883. [INFO] found homeassistant on local database 1590295383: New client connected from 172.30.32.1 as auto-3A4CBBDE-C9F0-6A6E-6929-C5524D4E4CCE (p2, c1, k60, u'homeassistant').
I don’t have any experience with MQTT; however, I know enough to realize it shouldn’t try to authenticate using the username: ‘homeassistant’ from the client IP: 172.30.32.1 .
All I know is 172.30.32.1 is the internal docker IP address.
I have no idea why I have to restart IOTLink exactly 3 times for it to connect. The odd thing is this behavior is extremely consistent.
I don’t have anything specified in my Configuration.yaml that’s related to MQTT; just the MQTT Broker configuration I posted above.
Could someone please help get my client to connect reliably the first time?
PS: If I don’t explicitly specify username/password in my MQTT Broker configuration, I get the error message in the supervisor log that login “mkanet” is wrong; even though the credential is correct (matching my Home Assistant username/password that I use to connect).
Thanks so much for your assistance!