Loosing connection to Home Assistant - do not know why

Hi,

Recently I have been loosing connection to Home Assistant on alla platforms. I use Nabu Casa, but problems also arise when I try to access Home Assistant at home via hasio.local and even slow and inconsistent when accessing the files in the card via Samba. Also my HomeKit integration fails to work.

I am quite sure that the SD card is working becaouse I can reboot (sometimes via Home assistant, sometimes by cutting the power and powering up again). and everything works fine a few hours.

The log is very long so I include som pieces. I can provide the full log if somebody wants to take a look at it.

After a while I do loose contact. Typically it starts with an increasing number of omponent error such as:

2020-05-04 00:37:12 ERROR (MainThread) [homeassistant.components.upnp] Timeout fetching F@st5370e Telia data

Additional errors start to pile up such as:

2020-05-04 00:39:06 ERROR (MainThread) [homeassistant.helpers.entity] Update for lock.huvudentre_koksingang fails

2020-05-04 00:44:01 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved

I also get an increasing amount of warnings such as:

2020-05-04 00:44:04 WARNING (SyncWorker_17) [homeassistant.components.sonos.media_player] Could not connect media_player.altan: Connection error: (‘Connection aborted.’, RemoteDisconnected(‘Remote end closed connection without response’))
2020-05-04 00:44:09 WARNING (SyncWorker_12) [homeassistant.components.sonos.media_player] Could not connect media_player.amanda: Connection error: HTTPConnectionPool(host=‘192.168.1.130’, port=1400): Read timed out.

Components affected include mediaplayer, verisure, harmony, sonos, dsm_synology and custom components sauch as hasl.

Additional problems seem to come (repeated several times):

2020-05-04 00:59:06 INFO (MainThread) [backoff] Backing off get_ratelimit(…) for 3.5s (concurrent.futures._base.TimeoutError)
2020-05-04 01:01:45 ERROR (MainThread) [backoff] Giving up get_ratelimit(…) after 5 tries (concurrent.futures._base.TimeoutError)

After a while I get the following error related to Nabu Casa:

2020-05-04 01:06:58 ERROR (MainThread) [hass_nabucasa.iot] Unexpected error
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 677, in urlopen
chunked=chunked,
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 381, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 976, in validate_conn
conn.connect()
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 370, in connect
ssl_context=context,
File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl
.py", line 377, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File “/usr/local/lib/python3.7/ssl.py”, line 423, in wrap_socket
session=session
File “/usr/local/lib/python3.7/ssl.py”, line 870, in _create
self.do_handshake()
File “/usr/local/lib/python3.7/ssl.py”, line 1139, in do_handshake
self._sslobj.do_handshake()
OSError: [Errno 0] Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/botocore/httpsession.py”, line 263, in send
chunked=self._chunked(request.headers),
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 725, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File “/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py”, line 379, in increment
raise six.reraise(type(error), error, _stacktrace)
File “/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py”, line 734, in reraise
raise value.with_traceback(tb)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 677, in urlopen
chunked=chunked,
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 381, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 976, in validate_conn
conn.connect()
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 370, in connect
ssl_context=context,
File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl
.py", line 377, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File “/usr/local/lib/python3.7/ssl.py”, line 423, in wrap_socket
session=session
File “/usr/local/lib/python3.7/ssl.py”, line 870, in _create
self.do_handshake()
File “/usr/local/lib/python3.7/ssl.py”, line 1139, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: (‘Connection aborted.’, OSError(0, ‘Error’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/hass_nabucasa/iot_base.py”, line 108, in connect
await self._handle_connection()
File “/usr/local/lib/python3.7/site-packages/hass_nabucasa/iot_base.py”, line 147, in _handle_connection
await self.cloud.auth.async_check_token()
File “/usr/local/lib/python3.7/site-packages/hass_nabucasa/auth.py”, line 174, in async_check_token
await self._async_renew_access_token()
File “/usr/local/lib/python3.7/site-packages/hass_nabucasa/auth.py”, line 201, in _async_renew_access_token
await self.cloud.run_executor(cognito.renew_access_token)
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/site-packages/pycognito/init.py”, line 620, in renew_access_token
AuthParameters=auth_params,
File “/usr/local/lib/python3.7/site-packages/botocore/client.py”, line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File “/usr/local/lib/python3.7/site-packages/botocore/client.py”, line 648, in _make_api_call
operation_model, request_dict, request_context)
File “/usr/local/lib/python3.7/site-packages/botocore/client.py”, line 667, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File “/usr/local/lib/python3.7/site-packages/botocore/endpoint.py”, line 102, in make_request
return self._send_request(request_dict, operation_model)
File “/usr/local/lib/python3.7/site-packages/botocore/endpoint.py”, line 137, in _send_request
success_response, exception):
File “/usr/local/lib/python3.7/site-packages/botocore/endpoint.py”, line 231, in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)
File “/usr/local/lib/python3.7/site-packages/botocore/hooks.py”, line 356, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File “/usr/local/lib/python3.7/site-packages/botocore/hooks.py”, line 228, in emit
return self._emit(event_name, kwargs)
File “/usr/local/lib/python3.7/site-packages/botocore/hooks.py”, line 211, in _emit
response = handler(**kwargs)
File “/usr/local/lib/python3.7/site-packages/botocore/retryhandler.py”, line 183, in call
if self._checker(attempts, response, caught_exception):
File “/usr/local/lib/python3.7/site-packages/botocore/retryhandler.py”, line 251, in call
caught_exception)
File “/usr/local/lib/python3.7/site-packages/botocore/retryhandler.py”, line 277, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File “/usr/local/lib/python3.7/site-packages/botocore/retryhandler.py”, line 317, in call
caught_exception)
File “/usr/local/lib/python3.7/site-packages/botocore/retryhandler.py”, line 223, in call
attempt_number, caught_exception)
File “/usr/local/lib/python3.7/site-packages/botocore/retryhandler.py”, line 359, in _check_caught_exception
raise caught_exception
File “/usr/local/lib/python3.7/site-packages/botocore/endpoint.py”, line 200, in _do_get_response
http_response = self._send(request)
File “/usr/local/lib/python3.7/site-packages/botocore/endpoint.py”, line 244, in _send
return self.http_session.send(request)
File “/usr/local/lib/python3.7/site-packages/botocore/httpsession.py”, line 294, in send
endpoint_url=request.url
botocore.exceptions.ConnectionClosedError: Connection was closed before we received a valid response from endpoint URL: “https://cognito-idp.us-east-1.amazonaws.com/”.

And then I get an ERROR rleated to snitun:

2020-05-04 01:12:09 ERROR (MainThread) [snitun.multiplexer.core] Ping fails, no response from peer

From there on I do not think much works.

I managed to access the files via Samba from which I got the log. Interestingly, the last log entry was the following:

2020-05-04 01:59:14 WARNING (MainThread) [homeassistant.components.lock] Updating verisure lock took longer than the scheduled update interval 0:00:30
2020-05-04 01:59:15 WARNING (MainThread) [homeassistant.components.sensor] Updating hasl sensor took longer than the scheduled update interval 0:00:30
2020-05-04 01:59:15 WARNING (MainThread) [hass_nabucasa.iot] Cannot connect because unable to refresh token:
2020-05-04 01:59:18 DEBUG (MainThread) [hass_nabucasa.remote] Don’t need refresh snitun token
2020-05-04 01:59:20 INFO (MainThread) [backoff] Backing off get_ratelimit(…) for 3.5s (concurrent.futures._base.TimeoutError)
2020-05-04 01:59:20 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/aiohttp/connector.py”, line 830, in _resolve_host
self._resolver.resolve(host, port, family=self._family)
File “/usr/local/lib/python3.7/site-packages/aiohttp/resolver.py”, line 30, in resolve
host, port, type=socket.SOCK_STREAM, family=family)
File “/usr/local/lib/python3.7/asyncio/base_events.py”, line 792, in getaddrinfo
None, getaddr_func, host, port, family, type, proto, flags)
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/socket.py”, line 752, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again
2020-05-04 01:59:23 ERROR (MainTh

Where you able to find a solution for this issue? I’m facing the exact same error where from time to time I get disconnected from Nabucasa and the homekit integration stops working. This happens every few hours, sometimes 3 or 4 times in the same day.

In the log I can see that everything stops when the following message is generated:
2020-05-29 15:22:11 ERROR (MainThread) [snitun.multiplexer.core] Ping fails, no response from peer
2020-05-29 15:22:21 ERROR (MainThread) [snitun.client.client_peer] Can’t connect to SniTun server us-east-1.ui.nabu.casa:443
2020-05-29 15:22:21 ERROR (MainThread) [hass_nabucasa.remote] Connection problem to snitun server

After that, I receive once every minute the messages:
2020-05-29 15:22:36 ERROR (MainThread) [snitun.client.client_peer] Can’t connect to SniTun server us-east-1.ui.nabu.casa:443
2020-05-29 15:22:36 ERROR (MainThread) [hass_nabucasa.remote] Connection problem to snitun server

The system never manages to re-connect unless I restart the server.

I’m currently running Hassio 0.110.3 on a VM over Oracle VM virtualbox on Windows 10 but the issue is happening since at least 0.109 .

Not solved.

I have a suspicion that it may have to do with my network (a switch or my router). I tried to reinstall on a new SD card but I have no even been able to connect to it. When I try to check my SD-cards in the computer I cannot find any error, but that is of course not a foolproof test.

im getting this now too
any fix?

I don’t know why, but my error seemed to be connected to the iphonedetect add-on. I still use the addon, but one of the ip-adresses that I used was no longer used by the router. Since I resolved that I have not had anymore problems.