core: SSL handshake error in Velux component

The problem

since 0.108.9 home assistant looses connection with Velux KLF-200.

Environment

  • Home Assistant Core release with the issue: 0.108.9
  • Last working Home Assistant Core release (if known): 0.108.8
  • Operating environment (Home Assistant/Supervised/Docker/venv): Home Assistant
  • Integration causing this issue: Velux
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/velux/

Problem-relevant configuration.yaml


velux:
  host: !secret velux_host
  password: !secret velux_password

Traceback/Error logs


Logger: homeassistant.setup
Source: components/velux/__init__.py:69
First occurred: 11:04:20 (1 occurrences)
Last logged: 11:04:20

Error during setup of component velux
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 171, in _async_setup_component
    hass, processed_config
  File "/usr/src/homeassistant/homeassistant/components/velux/__init__.py", line 31, in async_setup
    await hass.data[DATA_VELUX].async_start()
  File "/usr/src/homeassistant/homeassistant/components/velux/__init__.py", line 69, in async_start
    await self.pyvlx.load_scenes()
  File "/usr/local/lib/python3.7/site-packages/pyvlx/pyvlx.py", line 87, in load_scenes
    await self.scenes.load()
  File "/usr/local/lib/python3.7/site-packages/pyvlx/scenes.py", line 51, in load
    await get_scene_list.do_api_call()
  File "/usr/local/lib/python3.7/site-packages/pyvlx/api_event.py", line 22, in do_api_call
    await self.send_frame()
  File "/usr/local/lib/python3.7/site-packages/pyvlx/api_event.py", line 34, in send_frame
    await self.pyvlx.send_frame(self.request_frame())
  File "/usr/local/lib/python3.7/site-packages/pyvlx/pyvlx.py", line 70, in send_frame
    await self.connect()
  File "/usr/local/lib/python3.7/site-packages/pyvlx/pyvlx.py", line 45, in connect
    await self.connection.connect()
  File "/usr/local/lib/python3.7/site-packages/pyvlx/connection.py", line 89, in connect
    ssl=self.create_ssl_context())
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 989, in create_connection
    ssl_handshake_timeout=ssl_handshake_timeout)
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 1017, in _create_connection_transport
    await waiter
ConnectionAbortedError: SSL handshake is taking longer than 60.0 seconds: aborting the connection

Additional information

Only when rebooting the KLF-200, I can rectify the situation however, it reappears after the first reboot of home assistant

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 41 (16 by maintainers)

Most upvoted comments

@jcoetsie or @pawlizio or anyone can this issue be re-opened ? The issue is still here 😦

Please reopen, problem has resurfaced.

If it is python 3.7 you could try the following:

  •        ssl_handshake_timeout=5,
    

Has this timeout been introduced recently? Since I upgraded HA from 0.114 to 0.115 I couldn’t establish a connection with my KLF-200 anymore, I always got a timeout error at startup. I changed the timeout to 15s and it works again now. I only get a warning about the connection taking more than 10 seconds:

Logger: pyvlx
Source: /srv/homeassistant/lib/python3.7/site-packages/pyvlx/pyvlx.py:76
First occurred: 22:56:03 (1 occurrences)
Last logged: 22:56:03

Connected to: KLF 200: Software version: 0.2.0.0.71.0, hardware version: 6, protocol version: 3.14

Logger: homeassistant.setup
Source: /usr/lib/python3.7/asyncio/events.py:88
First occurred: 22:56:03 (1 occurrences)
Last logged: 22:56:03

Setup of velux is taking over 10 seconds.

The problem is, that KLF200 only can handle a handful of SSL connections and does not purge them automatically. See related issue here: https://github.com/Julius2342/pyvlx/issues/30

From looking into the code of HASS, it looks like the disconnect is called properly. May you add a debug output here to see if it passes this line: https://github.com/home-assistant/core/blob/dev/homeassistant/components/velux/__init__.py#L59