mqtt/mqtt_statestream causing multi-minute hangs on system shutdown due to ACK failures
Closed this issue · 10 comments
The problem
This was reported at home-assistant/addons#2250 but closed due to staleness. Also, I believe the issue is in Core rather than any Addon, as it seems related to homeassistant.components.mqtt and homeassistant.components.mqtt_statestream.
When attempting to restart through the UI, I am experiencing delays of several minutes every time. It appears to be related to mqtt_statestream events being sent, but no ACK being received. Each attempt results in an ACK-failure warning message 10 seconds later, and this continues for several minutes until the server finally restarts.
If I comment out the mqtt_statestream integration, restarts are very quick (10-15 seconds).
There are no similar ACK warnings during the course of normal operation, so it appears MQTT is working fine.
My guess is that a connection is being closed at shutdown prior to the ACKs being received, but I don't really know anything about the internals of HA/MQTT.
What version of Home Assistant Core has the issue?
core-2021.12.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
MQTT
Link to integration documentation on our website
https://www.home-assistant.io/docs/mqtt
Example YAML snippet
mqtt_statestream:
base_topic: homeassistant
publish_attributes: true
publish_timestamps: true
mqtt:
discovery: false
broker: emqx
client_id: homeassistant
username: !secret secret_mqtt_username
password: !secret secret_mqtt_password
birth_message:
topic: 'hass/status'
payload: 'online'
will_message:
topic: 'hass/status'
payload: 'offline'
Anything in the logs that might be useful for us?
2022-01-09 13:50:55 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on homeassistant/binary_sensor/[redacted]/state: 'unavailable', mid: 1596
2022-01-09 13:50:55 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on homeassistant/binary_sensor/[redacted]/state: 'unavailable', mid: 1597
2022-01-09 13:50:55 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on homeassistant/binary_sensor/[redacted]/state: 'unavailable', mid: 1598
[...many other messages elided...]
2022-01-09 13:51:05 WARNING (MainThread) [homeassistant.components.mqtt] No ACK from MQTT server in 10 seconds (mid: 1596)
2022-01-09 13:51:05 WARNING (MainThread) [homeassistant.components.mqtt] No ACK from MQTT server in 10 seconds (mid: 1597)
2022-01-09 13:51:05 WARNING (MainThread) [homeassistant.components.mqtt] No ACK from MQTT server in 10 seconds (mid: 1598)
Additional information
No response
mqtt_statestream documentation
mqtt_statestream source
(message by IssueLinks)
Hey there @emontnemery, mind taking a look at this issue as it has been labeled with an integration (mqtt
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
mqtt documentation
mqtt source
(message by IssueLinks)
can confirm having restart troubles with my MQTT instance using statestreams. didnt yet relate that to statestreams, but as it holds nothing much other than the MQTT add-on and a Deconz stick, it might very well be the same issue.
base_topic: ha_mqtt
include:
domains:
- device_tracker
entities:
- sensor.processor_temperature
is all I use, to publish the bluetooth device_trackers and 1 sensor.
will set the debug level to mqtt component and check for those messages.
@Mariusthvdb & @clang13 I am facing now the same problem. Have you found any solution yet?
Have you found any solution yet?
I have not, other than disabling mqtt_statestream.
OK, this is not enabled by default, if i see it right. Didn't enable that... Still that problem...
Hi @clang13 @Mariusthvdb Do yo use zigbee2mqtt? How many devices / entities do you have?
Maybe it has something to do with the discover messages or the number of devices / entites?
Do yo use zigbee2mqtt? How many devices / entities do you have?
No, I don't have any Zigbee devices. I do run ZWaveJS2MQTT but have only moved a couple devices over to it from my existing/previous HA solution, Hubitat. (Finishing the migration got de-prioritized by other events, alas.)
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.