core: MQTT cannot connect to mosquitto broker anymore

The problem

Running in Docker containers, my running setup had

mqtt:
  broker: mosquitto
  discovery: false

After the last update, a line appears in the log (appart from the depreciation warning):

2022-03-22 15:52:40 WARNING (MainThread) [homeassistant.components.mqtt.mixins] MQTT integration is not setup, skipping setup of manually configured MQTT sensor

So I try to re-configure the integration in the GUI. But when I enter the same data from the old config into the GUI, the answer is always “Verbindung fehlgeschlagen” (connection failed). I see three attempts to connect to mosquitto in mosquitto’s log files.

Entering into the container, I verified that the connection is indeed working:

bash-5.1# apk update
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
v3.14.4-5-ge13c4eb9da [https://dl-cdn.alpinelinux.org/alpine/v3.14/main]
v3.14.4-6-g7b889b7851 [https://dl-cdn.alpinelinux.org/alpine/v3.14/community]
OK: 14979 distinct packages available
bash-5.1# apk add busybox-extras
(1/1) Installing busybox-extras (1.33.1-r6)
Executing busybox-extras-1.33.1-r6.post-install
Executing busybox-1.33.1-r6.trigger
OK: 142 MiB in 174 packages
bash-5.1# telnet mosquitto 1883
Connected to mosquitto

Also tried to use the IP#, but same result, it’s always connection failed. I tried to get more log files by adding:

logger:
  default: warning
  logs:
    homeassistant.components.mqtt: debug

to configuration.yaml but without any extra information being printed.

Even using the public name of the mosquitto container, which I verified that this is running fine:

$ mosquitto_sub -h HOSTNAME -p 1883 -v -t '#'
tinkerforge/callback/ptc_bricklet/i72/temperature {"temperature": 2004}

doesn’t make any difference.

What version of Home Assistant Core has the issue?

core-2022.3.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

MQTT

Link to integration documentation on our website

https://www.home-assistant.io/integrations/mqtt

Diagnostics information

No response

Example YAML snippet

mqtt:
  broker: mosquitto
  discovery: false

Anything in the logs that might be useful for us?

2022-03-22 15:52:40 WARNING (MainThread) [homeassistant.components.mqtt.mixins] MQTT integration is not setup, skipping setup of manually configured MQTT sensor

mosquitto:

1647959957: New connection from 172.18.0.5:47093 on port 1883.
1647959958: Client <unknown> closed its connection.
1647959958: New connection from 172.18.0.5:42427 on port 1883.
1647959960: Client <unknown> closed its connection.
1647959960: New connection from 172.18.0.5:37403 on port 1883.
1647959962: Client <unknown> closed its connection.

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 35 (7 by maintainers)

Most upvoted comments

https://github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md

Create a new user for MQTT via your Home Assistant’s frontend Configuration -> Users (manage users) , (i.e. not on Mosquitto’s Configuration tab). Notes:

This name cannot be homeassistant or addon, those are reserved usernames. If you do not see the option to create a new user, ensure that Advanced Mode is enabled in your Home Assistant profile.

[…]

Home Assistant user management This add-on is attached to the Home Assistant user system, so MQTT clients can make use of these credentials. Local users may also still be set independently within the configuration options for the add-on. For the internal Home Assistant ecosystem, we register homeassistant and addons, so these may not be used as user names.

Came here for this issue after updating HA. Seems to be solved by simply clicking on both the username and password field in HA MQTT integration GUI, then clicking next. Without doing that when clicking next it could not connect. A bit odd.

I tried to do the same and got a “Failed to connect” when pressing next.

@Bascht74 I’ve hidden your messages which are related to the MQTT integration being overwhelmed when discovering a large number of entities when HA is starting, let’s get that sorted in #71088 👍