home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.07k stars 29.73k forks source link

Rflink TCP mode does not reconnect after successful connection #23577

Closed adrianmihalko closed 5 years ago

adrianmihalko commented 5 years ago

Home Assistant release with the issue:

0.92.0

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.):

Hass.io/Linux

Component/platform:

https://www.home-assistant.io/components/rflink/

Description of problem:

HA does not reconnect in TCP mode, after successfull connection was made. It should periodically check connection, to check if remote side is available.

My setup:

Rflink on Arduino connected to ESP8266 running Esp-Link (for TCP mode as in the component description).

  1. I start with Rflink device OFF:
2019-04-30 23:14:37 INFO (MainThread) [homeassistant.components.rflink] Initiating Rflink connection
2019-04-30 23:14:40 ERROR (MainThread) [homeassistant.components.rflink] Error connecting to Rflink, reconnecting in 10
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/rflink/__init__.py", line 221, in connect
    transport, protocol = await connection
  File "uvloop/loop.pyx", line 1904, in create_connection
  File "uvloop/loop.pyx", line 1883, in uvloop.loop.Loop.create_connection
OSError: [Errno 113] Host is unreachable
2019-04-30 23:14:50 WARNING (MainThread) [homeassistant.components.rflink] disconnected from Rflink, reconnecting
2019-04-30 23:14:50 INFO (MainThread) [homeassistant.components.rflink] Initiating Rflink connection
2019-04-30 23:14:53 ERROR (MainThread) [homeassistant.components.rflink] Error connecting to Rflink, reconnecting in 10
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/rflink/__init__.py", line 221, in connect
    transport, protocol = await connection
  File "uvloop/loop.pyx", line 1904, in create_connection
  File "uvloop/loop.pyx", line 1883, in uvloop.loop.Loop.create_connection
OSError: [Errno 113] Host is unreachable

Correct, until it is not available it tries to connect every 10 sec.

  1. I plug in Rflink device:
2019-04-30 23:15:29 INFO (MainThread) [homeassistant.components.rflink] Initiating Rflink connection
2019-04-30 23:15:29 DEBUG (MainThread) [rflink.protocol] connected
2019-04-30 23:15:29 INFO (MainThread) [homeassistant.components.rflink] Connected to Rflink
2019-04-30 23:15:46 DEBUG (MainThread) [rflink.protocol] received data: 20;00;Nodo RadioFrequencyLink - RFLink Gateway V1.1 - R48;

It is connected and received data.

Now, when for some reason connection is broken, or If I turn off Rflink device, HA does not check connection and never tries to reconnect, which means I must restart HA to restart connection to Rflink device.

Expected behavior:

After connection is broken, HA should check for connection based on interval reconnect_interval, if it is broken, try to reconnect.

Maybe reconnect_interval is only valid for local connections /dev/usb?

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

Traceback (if applicable):

Additional information:

KennieNL commented 5 years ago

I think I've used to have this issue, but I use the following socat now which makes it reconnect when the connection is down: socat pty,link=/config/serialport-rflink,echo=0 tcp:x.x.x.x:xxxx,forever,reuseaddr,keepalive,keepidle=10,keepintvl=10,keepcnt=2

genestealer commented 5 years ago

I found that the reconnect interval works fine for my identical set up. I appreciate this doesn't really help your situation but I thought it would be useful to know. ESP-Link to Arduino.

stale[bot] commented 5 years ago

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 now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.