Home Assistant randomly restarting by itself

I was having problems updating from 0.114 onwards, I then did a clean installation and restored the configuration, still no luck: now instead of becoming unresponsive indefinetely, it just restarts (even if it can be offline for several minutes)
Also tried a brand new microSD bought for this purpose, no improvement

Version
core-2021.1.4

I just managed to catch these errors

2021-01-20 19:55:51 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.ping_eolo is taking over 10 seconds
2021-01-20 19:56:50 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.ping_eolo is taking over 10 seconds
2021-01-20 19:56:57 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for sensor.energia_casa (<class 'homeassistant.components.integration.sensor.IntegrationSensor'>) took 0.406 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+integration%22
2021-01-20 19:57:21 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.ping_eolo is taking over 10 seconds
2021-01-20 19:57:51 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.ping_eolo is taking over 10 seconds
2021-01-20 19:58:20 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.cpu_temperature is taking over 10 seconds
2021-01-20 19:58:23 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.ping_eolo is taking over 10 seconds
2021-01-20 19:58:27 ERROR (SyncWorker_7) [homeassistant.components.command_line] Timeout for command: cat /sys/class/thermal/thermal_zone0/temp
2021-01-20 19:59:00 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.kitchen_on_today is taking over 10 seconds
2021-01-20 19:59:02 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for sensor.cucina_heating (<class 'homeassistant.components.tado.sensor.TadoZoneSensor'>) took 0.433 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+tado%22
2021-01-20 19:59:02 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.ping_eolo is taking over 10 seconds
2021-01-20 19:59:12 WARNING (MainThread) [homeassistant.components.binary_sensor] Updating ping binary_sensor took longer than the scheduled update interval 0:00:30
2021-01-20 19:59:24 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.cpu_temperature is taking over 10 seconds
2021-01-20 19:59:39 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547333549024] Client unable to keep up with pending messages. Stayed over 512 for 5 seconds
2021-01-20 19:59:44 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547333549024] Client unable to keep up with pending messages. Stayed over 512 for 5 seconds
2021-01-20 19:59:52 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.ping_eolo is taking over 10 seconds
2021-01-20 20:03:00 WARNING (MainThread) [homeassistant.helpers.entity] Updating state for sensor.casa_giornaliero_f1 (<class 'homeassistant.components.utility_meter.sensor.UtilityMeterSensor'>) took 12.548 seconds. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+utility_meter%22
2021-01-20 20:06:05 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=15 from 2021-01-20 19:14:02)
2021-01-20 20:06:21 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for rpi_power which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2021-01-20 20:06:22 WARNING (MainThread) [homeassistant.setup] Setup of utility_meter is taking over 10 seconds.
2021-01-20 20:08:11 WARNING (MainThread) [homeassistant.components.light] Setup of light platform mqtt is taking over 10 seconds.
2021-01-20 20:08:11 WARNING (MainThread) [homeassistant.components.switch] Setup of switch platform mqtt is taking over 10 seconds.
2021-01-20 20:08:11 WARNING (MainThread) [homeassistant.components.binary_sensor] Setup of binary_sensor platform mqtt is taking over 10 seconds.
2021-01-20 20:08:11 WARNING (MainThread) [homeassistant.components.binary_sensor] Setup of binary_sensor platform ping is taking over 10 seconds.
2021-01-20 20:08:11 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform systemmonitor is taking over 10 seconds.
2021-01-20 20:08:11 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform mqtt is taking over 10 seconds.
2021-01-20 20:08:11 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform filter is taking over 10 seconds.
2021-01-20 20:08:11 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform command_line is taking over 10 seconds.
2021-01-20 20:08:11 WARNING (MainThread) [homeassistant.setup] Setup of default_config is taking over 10 seconds.
2021-01-20 20:08:11 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: utility_meter, tado, default_config
2021-01-20 20:08:11 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 42, in get
    return await WebSocketHandler(request.app["hass"], request).async_handle()
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 141, in async_handle
    await wsock.prepare(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_ws.py", line 135, in prepare
    payload_writer = await super().prepare(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_response.py", line 378, in prepare
    return await self._start(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_response.py", line 386, in _start
    await self._write_headers()
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_response.py", line 458, in _write_headers
    await writer.write_headers(status_line, self._headers)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_writer.py", line 119, in write_headers
    self._write(buf)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport
2021-01-20 20:08:12 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 42, in get
    return await WebSocketHandler(request.app["hass"], request).async_handle()
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 141, in async_handle
    await wsock.prepare(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_ws.py", line 135, in prepare
    payload_writer = await super().prepare(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_response.py", line 378, in prepare
    return await self._start(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_response.py", line 386, in _start
    await self._write_headers()
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_response.py", line 458, in _write_headers
    await writer.write_headers(status_line, self._headers)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_writer.py", line 119, in write_headers
    self._write(buf)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport

Same here on 2021.1.5

2021-01-26 20:01:35 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 172, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 42, in get
    return await WebSocketHandler(request.app["hass"], request).async_handle()
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 141, in async_handle
    await wsock.prepare(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_ws.py", line 135, in prepare
    payload_writer = await super().prepare(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_response.py", line 378, in prepare
    return await self._start(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_response.py", line 386, in _start
    await self._write_headers()
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_response.py", line 458, in _write_headers
    await writer.write_headers(status_line, self._headers)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_writer.py", line 119, in write_headers
    self._write(buf)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport

Same here. It seems that livestream cards / are the issue here.

I have 6 Camera’s. 4 of them use Zoneminder and they work perfectly every time.
I also have 2 “smart” camera’s that do not work with RTPS and such they can only be viewed via a mobile app or a Windows executable. I’ve worked my way around this by capturing that stream to a file that get’s overwritten every few seconds and have set-up 2 picture entity cards.

If i remove or hide both those cards… everything turns normal again. But as soon as the page with the 2 camera’s is loaded the HA webserver goes down for a few seconds and comes back online (same error message as above).

  - platform: generic
    name: "Tuin"
    still_image_url: http://192.168.20.9/Smartwares/tuin/Region%201.jpeg
type: picture-glance
title: Tuin
entities: []
camera_image: camera.tuin
camera_view: live
tap_action:
  action: navigate
  navigation_path: tuin
hold_action:
  action: more-info
entity: camera.tuin

It might be something the aiohttp.server does not understand?

Logger: aiohttp.server
Source: helpers/aiohttp_client.py:172
First occurred: 5:53:36 PM (1 occurrences)
Last logged: 5:53:36 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 77, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 144, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 511, in get
    return await self.handle(request, camera)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 546, in handle
    stream = await camera.handle_async_mjpeg_stream(request)
  File "/usr/src/homeassistant/homeassistant/components/mjpeg/camera.py", line 163, in handle_async_mjpeg_stream
    return await async_aiohttp_proxy_web(self.hass, request, stream_coro)
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 142, in async_aiohttp_proxy_web
    return await async_aiohttp_proxy_stream(
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 172, in async_aiohttp_proxy_stream
    await response.write(data)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_response.py", line 470, in write
    await self._payload_writer.write(data)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/http_writer.py", line 107, in write
    self._write(chunk)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport

Home Assistant 2021.7.2

I am also seeing random HA application restarts, a few per day. Prior to this HA has been rock solid for years.

Running 2021.7.2 (the restarts started with 2021.6), RPi3b, docker container, zwavejs2mqtt.

No memory or power supply issues. I did notice errors related to the stream component. I have two picture-glances cards displaying the cams. One is ONVIF and the other one uses the TAPO custom component

The errors that I see are:

2021-07-14 19:00:26 ERROR (stream_worker) [libav.NULL] missing picture in access unit with size 127276
2021-07-14 19:11:30 ERROR (stream_worker) [libav.NULL] illegal reordering_of_pic_nums_idc 25
2021-07-14 19:13:18 ERROR (stream_worker) [libav.rtsp] Error parsing AU headers
2021-07-14 19:13:22 ERROR (stream_worker) [libav.NULL] missing picture in access unit with size 4462
2021-07-14 19:13:24 ERROR (stream_worker) [libav.NULL] missing picture in access unit with size 1452
2021-07-14 19:18:11 ERROR (stream_worker) [libav.NULL] missing picture in access unit with size 5802

I am not sure though if this is what ends up crashing HA

Does it go away when you temporary delete the picture entity card (or move it to another dashboard. it then should only crash when you open that dashboard) ?

Good question, I did not try removing the stream components yet (they have my security cams). What I just noticed is a 250MB core dump in the homeassistant configuration folder dated yesterday; the timestamp it doesn’t seem to correlate with the restart time but who knows. I haven’t updated the base OS and docker for about 6 months (it’s been so stable!) so I’m starting there. full-upgrade, reboot, and let’s see.

Well updating raspbian didnt help. HA still restarts itself and I could correlate the core dump generation with the HA restart.
The HA container itself does not restart, it’s the HA application inside that does it.
After the system updates I no longer see the stream component (python/ffmpeg) errors. Annoying problem :confused:

i did not ask you to permanently remove the card. just remove it for now. just to see if your issue will go away… if it does, we know that the card is causing an issue (probably). You do not have to look further then :slight_smile: