core icon indicating copy to clipboard operation
core copied to clipboard

Kodi integration slows down HA restart/shutdown

Open definitio opened this issue 3 years ago • 46 comments

The problem

When Kodi integration is enabled HA restart (or shutdown) takes a few minutes if there is no connection to kodi. I have this problem for 2-3 months (after moving configuration to UI).

What is version of Home Assistant Core has the issue?

2021.3.3

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

Kodi

Link to integration documentation on our website

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

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Log:

2021-03-18 15:07:53 WARNING (MainThread) [homeassistant.core] Timed out waiting for shutdown stage 1 to complete, the shutdown will continue
2021-03-18 15:07:59 DEBUG (MainThread) [homeassistant.components.kodi.media_player] Unable to connect to Kodi via websocket
Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection                                                                                                                   
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa                                                                                                                                       
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection                                                                                                                                    
    raise exceptions[0]                                                                                                                                                                                                      
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection                                                                                                                                    
    sock = await self._connect_sock(                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock                                                                                                                                         
    await self.sock_connect(sock, address)                                                                                                                                                                                   
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect                                                                                                                                      
    return await fut                                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb                                                                                                                                  
    raise OSError(err, f'Connect call failed {address}')                                                                                                                                                                     
TimeoutError: [Errno 110] Connect call failed ('10.10.1.91', 9090)                                                                                                                                                           

The above exception was the direct cause of the following exception:                                                                                                                                                         

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 63, in ws_connect                                                                                                                         
    self._client = await self._session.ws_connect(                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 754, in _ws_connect                                                                                                                                  
    resp = await self.request(                                                                                                                                                                                               
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request                                                                                                                                     
    conn = await self._connector.connect(                                                                                                                                                                                    
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect                                                                                                                                   
    proto = await self._create_connection(req, traces, timeout)                                                                                                                                                              
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection                                                                                                                        
    _, proto = await self._create_direct_connection(req, traces, timeout)                                                                                                                                                    
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection                                                                                                                
    raise last_exc                                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection                                                                                                                
    transp, proto = await self._wrap_create_connection(                                                                                                                                                                      
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection                                                                                                                   
    raise client_error(req.connection_key, exc) from exc                                                                                                                                                                     
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host lroom-tv.lan:9090 ssl:default [Connect call failed ('10.10.1.91', 9090)]                                                                              

During handling of the above exception, another exception occurred:                                                                                                                                                          

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/pykodi/kodi.py", line 135, in connect                                                                                                                                         
    await self._ws_server.ws_connect()                                                                                                                                                                                       
  File "/usr/local/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 66, in ws_connect                                                                                                                         
    raise TransportError('Error connecting to server', None, exc)                                                                                                                                                            
jsonrpc_base.jsonrpc.TransportError: ('Error connecting to server', ClientConnectorError(ConnectionKey(host='lroom-tv.lan', port=9090, is_ssl=False, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=4231791446501600363), TimeoutError(110, "Connect call failed ('10.10.1.91', 9090)")))                                                                                                                                                      

The above exception was the direct cause of the following exception:                                                                                                                                                         

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/src/homeassistant/homeassistant/components/kodi/media_player.py", line 409, in _async_ws_connect                                                                                                                
    await self._connection.connect()                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/site-packages/pykodi/kodi.py", line 137, in connect                                                                                                                                         
    raise CannotConnectError from error                                                                                                                                                                                      
pykodi.kodi.CannotConnectError                                                                                                                                                                                               
2021-03-18 15:08:09 DEBUG (MainThread) [homeassistant.components.kodi.media_player] Unable to connect to Kodi via websocket
Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection                                                                                                                   
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa                                                                                                                                       
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection                                                                                                                                    
    raise exceptions[0]                                                                                                                                                                                                      
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection                                                                                                                                    
    sock = await self._connect_sock(                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock                                                                                                                                         
    await self.sock_connect(sock, address)                                                                                                                                                                                   
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect                                                                                                                                      
    return await fut                                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb                                                                                                                                  
    raise OSError(err, f'Connect call failed {address}')                                                                                                                                                                     
TimeoutError: [Errno 110] Connect call failed ('10.10.1.91', 9090)                                                                                                                                                           

The above exception was the direct cause of the following exception:                                                                                                                                                         

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 63, in ws_connect                                                                                                                         
    self._client = await self._session.ws_connect(                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 754, in _ws_connect                                                                                                                                  
    resp = await self.request(                                                                                                                                                                                               
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request                                                                                                                                     
    conn = await self._connector.connect(                                                                                                                                                                                    
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect                                                                                                                                   
    proto = await self._create_connection(req, traces, timeout)                                                                                                                                                              
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection                                                                                                                        
    _, proto = await self._create_direct_connection(req, traces, timeout)                                                                                                                                                    
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection                                                                                                                
    raise last_exc                                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection                                                                                                                
    transp, proto = await self._wrap_create_connection(                                                                                                                                                                      
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection                                                                                                                   
    raise client_error(req.connection_key, exc) from exc                                                                                                                                                                     
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host lroom-tv.lan:9090 ssl:default [Connect call failed ('10.10.1.91', 9090)]                                                                              

During handling of the above exception, another exception occurred:                                                                                                                                                          

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/pykodi/kodi.py", line 135, in connect                                                                                                                                         
    await self._ws_server.ws_connect()                                                                                                                                                                                       
  File "/usr/local/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 66, in ws_connect                                                                                                                         
    raise TransportError('Error connecting to server', None, exc)                                                                                                                                                            
jsonrpc_base.jsonrpc.TransportError: ('Error connecting to server', ClientConnectorError(ConnectionKey(host='lroom-tv.lan', port=9090, is_ssl=False, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=4231791446501600363), TimeoutError(110, "Connect call failed ('10.10.1.91', 9090)")))                                                                                                                                                      

The above exception was the direct cause of the following exception:                                                                                                                                                         

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/src/homeassistant/homeassistant/components/kodi/media_player.py", line 409, in _async_ws_connect                                                                                                                
    await self._connection.connect()                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/site-packages/pykodi/kodi.py", line 137, in connect                                                                                                                                         
    raise CannotConnectError from error                                                                                                                                                                                      
pykodi.kodi.CannotConnectError                                                                                                                                                                                               
2021-03-18 15:08:20 DEBUG (MainThread) [homeassistant.components.kodi.media_player] Unable to connect to Kodi via websocket
Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection                                                                                                                   
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa                                                                                                                                       
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection                                                                                                                                    
    raise exceptions[0]                                                                                                                                                                                                      
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection                                                                                                                                    
    sock = await self._connect_sock(                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock                                                                                                                                         
    await self.sock_connect(sock, address)                                                                                                                                                                                   
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect                                                                                                                                      
    return await fut                                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb                                                                                                                                  
    raise OSError(err, f'Connect call failed {address}')                                                                                                                                                                     
TimeoutError: [Errno 110] Connect call failed ('10.10.1.91', 9090)                                                                                                                                                           

The above exception was the direct cause of the following exception:                                                                                                                                                         

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 63, in ws_connect                                                                                                                         
    self._client = await self._session.ws_connect(                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 754, in _ws_connect                                                                                                                                  
    resp = await self.request(                                                                                                                                                                                               
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request                                                                                                                                     
    conn = await self._connector.connect(                                                                                                                                                                                    
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect                                                                                                                                   
    proto = await self._create_connection(req, traces, timeout)                                                                                                                                                              
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection                                                                                                                        
    _, proto = await self._create_direct_connection(req, traces, timeout)                                                                                                                                                    
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection                                                                                                                
    raise last_exc                                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection                                                                                                                
    transp, proto = await self._wrap_create_connection(                                                                                                                                                                      
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection                                                                                                                   
    raise client_error(req.connection_key, exc) from exc                                                                                                                                                                     
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host lroom-tv.lan:9090 ssl:default [Connect call failed ('10.10.1.91', 9090)]                                                                              

During handling of the above exception, another exception occurred:                                                                                                                                                          

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/pykodi/kodi.py", line 135, in connect                                                                                                                                         
    await self._ws_server.ws_connect()                                                                                                                                                                                       
  File "/usr/local/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 66, in ws_connect                                                                                                                         
    raise TransportError('Error connecting to server', None, exc)                                                                                                                                                            
jsonrpc_base.jsonrpc.TransportError: ('Error connecting to server', ClientConnectorError(ConnectionKey(host='lroom-tv.lan', port=9090, is_ssl=False, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=4231791446501600363), TimeoutError(110, "Connect call failed ('10.10.1.91', 9090)")))                                                                                                                                                      

The above exception was the direct cause of the following exception:                                                                                                                                                         

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/src/homeassistant/homeassistant/components/kodi/media_player.py", line 409, in _async_ws_connect                                                                                                                
    await self._connection.connect()                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/site-packages/pykodi/kodi.py", line 137, in connect                                                                                                                                         
    raise CannotConnectError from error                                                                                                                                                                                      
pykodi.kodi.CannotConnectError                                                                                                                                                                                               
2021-03-18 15:08:30 DEBUG (MainThread) [homeassistant.components.kodi.media_player] Unable to connect to Kodi via websocket
Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection                                                                                                                   
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa                                                                                                                                       
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection                                                                                                                                    
    raise exceptions[0]                                                                                                                                                                                                      
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection                                                                                                                                    
    sock = await self._connect_sock(                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock                                                                                                                                         
    await self.sock_connect(sock, address)                                                                                                                                                                                   
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect                                                                                                                                      
    return await fut                                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb                                                                                                                                  
    raise OSError(err, f'Connect call failed {address}')                                                                                                                                                                     
TimeoutError: [Errno 110] Connect call failed ('10.10.1.91', 9090)                                                                                                                                                           

The above exception was the direct cause of the following exception:                                                                                                                                                         

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 63, in ws_connect                                                                                                                         
    self._client = await self._session.ws_connect(                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 754, in _ws_connect                                                                                                                                  
    resp = await self.request(                                                                                                                                                                                               
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request                                                                                                                                     
    conn = await self._connector.connect(                                                                                                                                                                                    
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect                                                                                                                                   
    proto = await self._create_connection(req, traces, timeout)                                                                                                                                                              
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection                                                                                                                        
    _, proto = await self._create_direct_connection(req, traces, timeout)                                                                                                                                                    
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection                                                                                                                
    raise last_exc                                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection                                                                                                                
    transp, proto = await self._wrap_create_connection(                                                                                                                                                                      
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection                                                                                                                   
    raise client_error(req.connection_key, exc) from exc                                                                                                                                                                     
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host lroom-tv.lan:9090 ssl:default [Connect call failed ('10.10.1.91', 9090)]                                                                              

During handling of the above exception, another exception occurred:                                                                                                                                                          

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/pykodi/kodi.py", line 135, in connect                                                                                                                                         
    await self._ws_server.ws_connect()                                                                                                                                                                                       
  File "/usr/local/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 66, in ws_connect                                                                                                                         
    raise TransportError('Error connecting to server', None, exc)                                                                                                                                                            
jsonrpc_base.jsonrpc.TransportError: ('Error connecting to server', ClientConnectorError(ConnectionKey(host='lroom-tv.lan', port=9090, is_ssl=False, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=4231791446501600363), TimeoutError(110, "Connect call failed ('10.10.1.91', 9090)")))                                                                                                                                                      

The above exception was the direct cause of the following exception:                                                                                                                                                         

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/src/homeassistant/homeassistant/components/kodi/media_player.py", line 409, in _async_ws_connect                                                                                                                
    await self._connection.connect()                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/site-packages/pykodi/kodi.py", line 137, in connect                                                                                                                                         
    raise CannotConnectError from error                                                                                                                                                                                      
pykodi.kodi.CannotConnectError                                                                                                                                                                                               
2021-03-18 15:08:40 DEBUG (MainThread) [homeassistant.components.kodi.media_player] Unable to connect to Kodi via websocket
Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection                                                                                                                   
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa                                                                                                                                       
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection                                                                                                                                    
    raise exceptions[0]                                                                                                                                                                                                      
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection                                                                                                                                    
    sock = await self._connect_sock(                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock                                                                                                                                         
    await self.sock_connect(sock, address)                                                                                                                                                                                   
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect                                                                                                                                      
    return await fut                                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb                                                                                                                                  
    raise OSError(err, f'Connect call failed {address}')                                                                                                                                                                     
TimeoutError: [Errno 110] Connect call failed ('10.10.1.91', 9090)                                                                                                                                                           

The above exception was the direct cause of the following exception:                                                                                                                                                         

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 63, in ws_connect                                                                                                                         
    self._client = await self._session.ws_connect(                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 754, in _ws_connect                                                                                                                                  
    resp = await self.request(                                                                                                                                                                                               
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request                                                                                                                                     
    conn = await self._connector.connect(                                                                                                                                                                                    
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect                                                                                                                                   
    proto = await self._create_connection(req, traces, timeout)                                                                                                                                                              
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection                                                                                                                        
    _, proto = await self._create_direct_connection(req, traces, timeout)                                                                                                                                                    
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection                                                                                                                
    raise last_exc                                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection                                                                                                                
    transp, proto = await self._wrap_create_connection(                                                                                                                                                                      
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection                                                                                                                   
    raise client_error(req.connection_key, exc) from exc                                                                                                                                                                     
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host lroom-tv.lan:9090 ssl:default [Connect call failed ('10.10.1.91', 9090)]                                                                              

During handling of the above exception, another exception occurred:                                                                                                                                                          

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/pykodi/kodi.py", line 135, in connect                                                                                                                                         
    await self._ws_server.ws_connect()                                                                                                                                                                                       
  File "/usr/local/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 66, in ws_connect                                                                                                                         
    raise TransportError('Error connecting to server', None, exc)                                                                                                                                                            
jsonrpc_base.jsonrpc.TransportError: ('Error connecting to server', ClientConnectorError(ConnectionKey(host='lroom-tv.lan', port=9090, is_ssl=False, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=4231791446501600363), TimeoutError(110, "Connect call failed ('10.10.1.91', 9090)")))                                                                                                                                                      

The above exception was the direct cause of the following exception:                                                                                                                                                         

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/src/homeassistant/homeassistant/components/kodi/media_player.py", line 409, in _async_ws_connect                                                                                                                
    await self._connection.connect()                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/site-packages/pykodi/kodi.py", line 137, in connect                                                                                                                                         
    raise CannotConnectError from error                                                                                                                                                                                      
pykodi.kodi.CannotConnectError                                                                                                                                                                                               
2021-03-18 15:08:50 DEBUG (MainThread) [homeassistant.components.kodi.media_player] Unable to connect to Kodi via websocket
Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection                                                                                                                   
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa                                                                                                                                       
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection                                                                                                                                    
    raise exceptions[0]                                                                                                                                                                                                      
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection                                                                                                                                    
    sock = await self._connect_sock(                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock                                                                                                                                         
    await self.sock_connect(sock, address)                                                                                                                                                                                   
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect                                                                                                                                      
    return await fut                                                                                                                                                                                                         
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb                                                                                                                                  
    raise OSError(err, f'Connect call failed {address}')                                                                                                                                                                     
TimeoutError: [Errno 110] Connect call failed ('10.10.1.91', 9090)                                                                                                                                                           

The above exception was the direct cause of the following exception:                                                                                                                                                         

Traceback (most recent call last):                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 63, in ws_connect                                                                                                                         
    self._client = await self._session.ws_connect(                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 754, in _ws_connect                                                                                                                                  
    resp = await self.request(                                                                                                                                                                                               
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 520, in _request                                                                                                                                     
    conn = await self._connector.connect(                                                                                                                                                                                    
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 535, in connect                                                                                                                                   
    proto = await self._create_connection(req, traces, timeout)                                                                                                                                                              
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 892, in _create_connection                                                                                                                        
    _, proto = await self._create_direct_connection(req, traces, timeout)                                                                                                                                                    
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection                                                                                                                
    raise last_exc                                                                                                                                                                                                           
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection                                                                                                                
    transp, proto = await self._wrap_create_connection(                                                                                                                                                                      
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection                                                                                                                   
    raise client_error(req.connection_key, exc) from exc                                                                                                                                                                     
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host lroom-tv.lan:9090 ssl:default [Connect call failed ('10.10.1.91', 9090)]                                                                              

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pykodi/kodi.py", line 135, in connect
    await self._ws_server.ws_connect()
  File "/usr/local/lib/python3.8/site-packages/jsonrpc_websocket/jsonrpc.py", line 66, in ws_connect
    raise TransportError('Error connecting to server', None, exc)
jsonrpc_base.jsonrpc.TransportError: ('Error connecting to server', ClientConnectorError(ConnectionKey(host='lroom-tv.lan', port=9090, is_ssl=False, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=4231791446501600363), TimeoutError(110, "Connect call failed ('10.10.1.91', 9090)")))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/kodi/media_player.py", line 409, in _async_ws_connect
    await self._connection.connect()
  File "/usr/local/lib/python3.8/site-packages/pykodi/kodi.py", line 137, in connect
    raise CannotConnectError from error
pykodi.kodi.CannotConnectError
2021-03-18 15:08:53 WARNING (MainThread) [homeassistant.core] Timed out waiting for shutdown stage 2 to complete, the shutdown will continue
Timed out waiting for shutdown stage 3 to complete, the shutdown will continue

I also have an other problem with Kodi: https://github.com/home-assistant/core/issues/38659

definitio avatar Mar 12 '21 19:03 definitio

Hey there @onfreund, @cgtobi, mind taking a look at this issue as its been labeled with an integration (kodi) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

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.

github-actions[bot] avatar Jun 16 '21 13:06 github-actions[bot]

It's still actual.

definitio avatar Jun 16 '21 14:06 definitio

Same for me.

Shamshala avatar Jun 19 '21 22:06 Shamshala

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.

github-actions[bot] avatar Sep 17 '21 23:09 github-actions[bot]

It's still actual.

definitio avatar Sep 18 '21 17:09 definitio

Also happens for me. After my kodi went offline, even whole home assistant history graph stopped working.

See flat lines here:

When restarted, restart hangs while trying to connect to kodi.

After removing Kodi integration, all was smooth again.

Looks like Kodi integration needs to implement async discovery as other integrations already do.

I am using HA 2021.10.6

hcw70 avatar Nov 02 '21 09:11 hcw70

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.

github-actions[bot] avatar Jan 31 '22 10:01 github-actions[bot]

It's still actual.

definitio avatar Feb 01 '22 17:02 definitio

It is still actual for me as well. Kodi is hanging all HA after reboot process.

Wampukas avatar Feb 19 '22 14:02 Wampukas

Same problem for me. Kodi takes more than 2 minutes to start.

PedroDelCargo avatar Mar 08 '22 13:03 PedroDelCargo

Same here...

c-lega avatar Mar 11 '22 00:03 c-lega

Yes, it's annoying. It needs an option to set a timeout to 5secs or something, rather than the default minutes.

quadhammer avatar May 10 '22 02:05 quadhammer

The issue is related to zeroconf integration. Sometimes an error appears on restart:

2022-06-12 14:38:48 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_services/browser.py", line 445, in _async_start_query_sender
    await self.zc.async_wait_for_start()
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_core.py", line 507, in async_wait_for_start
    raise NotRunningException
zeroconf._exceptions.NotRunningException

Disabling zeroconf fixes slow restart/shutdown.

UPD: This workaround doesn't work for me anymore.

definitio avatar Jun 12 '22 12:06 definitio

I have a better workaround:

  1. Forward all packets to 9090 port via a reverse proxy.
  2. Reject packets to Kodi when the first rule doesn't match. HA takes less than a minute to restart.

definitio avatar Jul 09 '22 17:07 definitio

I don't understand how that works, nor how to implement it. Hopefully someone maintaining this integration can come up with a more user-friendly solution.

We can't be the only people who don't have Kodi running permanently,, and thus have to wait over 2 minutes for home assistant to load.

quadhammer avatar Sep 18 '22 05:09 quadhammer

Have been setting up home assistant recently and kodi is one of my first integrations. Facing the same issue as well. Since adding kodi integration, ha startup takes a long time... as all my kodi instances are not available when not in use... :(

h3llrais3r avatar Jan 03 '23 20:01 h3llrais3r

Must say this has been a long time issue, about year ago removed the Kodi integration only to add it again today. Restart Home Assistant to remind me why I removed it to begin wth. The startup time is ridiculous and is the only reason my HA won't start in a few seconds, instead it's around 30x added to the start up time simply because I don't have the kodi instance up and running, The timeout needs to be shortened or make connection attempts in longer timeouts after startup.

For now, I might have to override the integration with custom docker files but really don't want to resort to this,

Sian-Lee-SA avatar Feb 19 '23 05:02 Sian-Lee-SA

Probably found the cause: see https://github.com/home-assistant/core/issues/73097

h3llrais3r avatar Feb 21 '23 20:02 h3llrais3r

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.

Up

ildar170975 avatar May 22 '23 22:05 ildar170975

This is still, (a very annoying) issue.

quadhammer avatar May 22 '23 23:05 quadhammer

Probably found the cause: see #73097

Seems that thread didn't come to a solution?

Sian-Lee-SA avatar May 22 '23 23:05 Sian-Lee-SA

No, no progress on any path... not here and not in aiohttp... :(

h3llrais3r avatar May 23 '23 05:05 h3llrais3r

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.

It's still broken. It's still annoying.

quadhammer avatar Aug 21 '23 05:08 quadhammer

Also still affects me.

hcw70 avatar Aug 21 '23 07:08 hcw70

Still the same here aswell.

PedroDelCargo avatar Aug 21 '23 07:08 PedroDelCargo

Same here! Annoying, annoying, annoying...

segoz avatar Sep 16 '23 14:09 segoz

Is there at least a way to disable the kodi integration on shutdown and reenable it after startup?

krasatos avatar Sep 16 '23 20:09 krasatos