8000 MQTT not reconnecting if disconnected from broker · Issue #8589 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

MQTT not reconnecting if disconnected from broker #8589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
syphernl opened this issue Jul 21, 2017 · 9 comments
Closed

MQTT not reconnecting if disconnected from broker #8589

syphernl opened this issue Jul 21, 2017 · 9 comments

Comments

@syphernl
Copy link
Contributor

Home Assistant release (hass --version):
0.49

Python release (python3 --version):
Python 3.5.2

Component/platform:
mqtt

Description of problem:
A few days ago I have restarted my MQTT broker during system maintenance.
I noticed about 15-30 minutes later that my MQTT-based items were no longer being updated.

The logs in the HA interface mentioned

WARNING (Thread-12) [homeassistant.components.mqtt] Disconnected from MQTT (1). Trying to reconnect in 1 s

I had to restart HA in order to get MQTT back to work properly.

Expected:

  1. HA to properly reconnect if the MQTT broker is temporarily unavailable
  2. A log line to be written stating that the connection has been restored.

Problem-relevant configuration.yaml entries and steps to reproduce:

mqtt:
  broker: !secret mqtt_host
  client_id: !secret mqtt_client_id
  keepalive: 60
  protocol: 3.1
  port: 8883
  username: !secret mqtt_username
  password: !secret mqtt_password
  certificate: /etc/ssl/certs/StartCom_Certification_Authority.pem
@kiwinol
Copy link
kiwinol commented Jul 22, 2017

I seem to have a similar issue.

Home Assistant release (hass --version):
0.49

Python release (python3 --version):
Python 3.4.2

Component/platform:
mqtt

mqtt:
  broker: 192.168.1.33
  port: 1883
  client_id: home-assistant-1
  username: !secret
  password: !secret
  discovery: false

Description:
after HA looses connectivity to mosquitto it gets out of sync. It can send commands to MQTT switches but doesnt seem to have the correct status information. If my switch was on HA assumes its off even though I can see the topic via MQTT the switch is showing its status as on.

Also if I try to turn on the switch via HA I see that the on command is sent to mosquitto (even though its already on) but the status is still not updated in HA.

Let me know if I can provide any other useful information.

@davidorlea
Copy link

Experiencing the same with 0.49: After the MQTT connection was interrupted, Home Assistant reconnects to the broker, but ignores incoming messages to the state_topic. However, messages are still published to the command_topic by Home Assistant.

Looks like Home Assistant is not correctly re-subscribing after connection interruptions.

@pezinek
Copy link
Contributor
pezinek commented Aug 8, 2017

Seems like the same issue as #7958

@marthoc
Copy link
Contributor
marthoc commented Sep 5, 2017

I'm having a similar issue on 0.52.1 with HA and Mosquitto and a MQTT Cover. When HA restarts, it loses the status of the Cover, though it can still publish messages to the command_topic (whereupon it will receive a new status update and then the GUI will show the correct state).

I'm not sure if this is limited to the MQTT Cover platform, as an MQTT Binary Sensor I've set up to monitor the same status_topic is showing the correct state after HA restart. It appears that the MQTT Cover is ignoring the fact that there is a retained message on the status_topic with the correct state but the Binary Sensor is not.

@pezinek
Copy link
Contributor
pezinek commented Sep 7, 2017

Could be in fact related to this paho bug: eclipse-paho/paho.mqtt.python#208

@marthoc
Copy link
Contributor
marthoc commented Sep 14, 2017

Just an update after further testing: the problem appears to be mqtt platform wide and not just with the cover - it just appeared that way to me since the cover's state with no retained message is set to "unknown" while the Binary sensor's state defaults to "off". It may be worth standardizing this across all mqtt devices to "unknown" so as not to mislead users into thinking their device has an accurate state when it may not. I may look into doing just this and raising a pull request at some point.

@tinloaf
Copy link
Contributor
tinloaf commented Sep 29, 2017

I suspect I'm also hit by this bug. The paho bug eclipse-paho/paho.mqtt.python#208 has just been (supposedly) fixed. I think we should try upgrading our paho installation as soon as they release the fix and see if that fixes the issue.

@pezinek
Copy link
Contributor
pezinek commented Oct 16, 2017

pahoo have been upgraded to 1.3.1 by #9874 may be worth re-testing this issue using the latest bits.

@pelson
Copy link
Contributor
pelson commented Feb 3, 2018

#10133 claims to have fixed this issue. Perhaps this issue should be closed?

@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants
0