core: Home Assistant crashes when "large" integrations reload

The problem

When ZwaveJS crashes or is unexpectedly restarted, it oversaturates HA’s connection pool, causing HA to restart. This has been happening for over a year (and I keep HA and ZwaveJS up to date), so is not a new behavior introduced recently. I discovered this because Proxmox sometimes seems to lose the Z-wave USB stick, so I have to physically pull it, re-insert, and restart the ZwaveJS Docker container. I am running HA and ZwaveJS in two separate containers.

I do not believe the ZwaveJS component is responsible for this, I just think it surfaces a websocket connection pool issue because I have 150 devices and 8,000+ entities in that integration. Once bad things start happening, you can see every component start timing out on it’s own connections. When this happens, the HA frontend becomes completely unresponsive, and the system appears to take several minutes to fix itself (not sure how).

Repro Steps:

  1. Notice that z-wave devices are not responding.
  2. Look at the ZwaveJS host, run lsusb and see that the stick is not in the list (I realize this has nothing to do with HA).
  3. Pull USB stick, re-insert it.
  4. Restart ZwaveJS container (docker compose stop and docker compose up -d).
  5. All hell breaks loose with HA for ~10 minutes.

Apologies if I’ve left anything out. Please let me know if there is some sort of aiohttp debugging I can do. It sucks to repro, because I have to do it on my production system and it brings my house to a grinding halt, but it is also somewhat easy to repro, so I can do that.

What version of Home Assistant Core has the issue?

core-2025.1.2

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

zwave_js

Link to integration documentation on our website

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

Diagnostics information

config_entry-zwave_js-3bc28dda636cbcd5827ba74c1529bbbc-2.json

Example YAML snippet


Anything in the logs that might be useful for us?

This is the relevant part of the log:


2025-01-25 04:02:23.357 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140401408617648] tablet from 192.168.2.132 (Mozilla/5.0 (iPad; CPU OS 15_8_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Kiosker Pro/22.23.1): Client unable to keep up with pending messages. Reached 4096 pending messages. The system's load is too high or an integration is misbehaving; Last message was: b'{"type":"event","event":{"event_type":"state_changed","data":{"entity_id":"number.basement_keypad_0x50_node_identify_multilevel","old_state":{"entity_id":"number.basement_keypad_0x50_node_identify_multilevel","state":"0.0","attributes":{"min":0.0,"max":255.0,"step":1.0,"mode":"auto","friendly_name":"Basement Keypad 0x50 (Node Identify) - Multilevel"},"last_changed":"2025-01-24T23:55:59.619981+00:00","last_reported":"2025-01-24T23:55:59.619981+00:00","last_updated":"2025-01-24T23:55:59.619981+00:00","context":{"id":"01JJDBWW830DS33KWTHV64TE09","parent_id":null,"user_id":null}},"new_state":{"entity_id":"number.basement_keypad_0x50_node_identify_multilevel","state":"unavailable","attributes":{"restored":true,"min":0.0,"max":255.0,"step":1.0,"mode":"auto","friendly_name":"0x50 (Node Identify) - Multilevel","supported_features":0},"last_changed":"2025-01-25T04:02:23.357306+00:00","last_reported":"2025-01-25T04:02:23.357306+00:00","last_updated":"2025-01-25T04:02:23.357306+00:00","context":{"id":"01JJDT01FXE0YHYMYS1RX9DY7M","parent_id":null,"user_id":null}}},"origin":"LOCAL","time_fired":"2025-01-25T04:02:23.357306+00:00","context":{"id":"01JJDT01FXE0YHYMYS1RX9DY7M","parent_id":null,"user_id":null}},"id":36}'
2025-01-25 04:04:41.338 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.boys_room_high] Error from stream worker: Stream ended; no additional packets
2025-01-25 04:04:49.959 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.basement_high] Error from stream worker: Stream ended; no additional packets
2025-01-25 04:05:22.750 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.boys_room_high] Error from stream worker: Stream ended; no additional packets
2025-01-25 04:05:29.948 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.basement_high] Error from stream worker: Stream ended; no additional packets
2025-01-25 04:05:46.253 WARNING (MainThread) [aioesphomeapi.connection] esp32-bluetooth-proxy-bd10f0 @ 192.168.2.189: Connection error occurred: esp32-bluetooth-proxy-bd10f0 @ 192.168.2.189: EOF received
2025-01-25 04:05:46.319 WARNING (MainThread) [aioesphomeapi.connection] esp32-bluetooth-proxy-basement @ 192.168.2.131: Connection error occurred: esp32-bluetooth-proxy-basement @ 192.168.2.131: EOF received
2025-01-25 04:05:46.322 WARNING (MainThread) [aioesphomeapi.connection] bed-presence-f552f8 @ 192.168.2.39: Connection error occurred: bed-presence-f552f8 @ 192.168.2.39: EOF received
2025-01-25 04:05:53.142 WARNING (MainThread) [aioesphomeapi.connection] gl-s10-bt-proxy-295b5c @ 192.168.2.49: Connection error occurred: [Errno 32] Broken pipe
2025-01-25 04:05:53.414 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall light.turn_on (c:01JJDT68CK:al:JZUW:ntrv:SA): entity_id=['light.foyer_nightlight'], params=brightness=86, color_temp=500, color_temp_kelvin=2000>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 2815, in _run_service_call_catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 2838, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/hass_utils.py", line 62, in service_func_proxy
    await existing_service.job.target(call)
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1006, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
        hass, entity, func, data, call.context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1078, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 644, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 313, in async_turn_on
    await self._set_color_temp(color_temp_kelvin, transition)
  File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 146, in _set_color_temp
    await self.send_device_command(
    ...<9 lines>...
    )
  File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 287, in send_device_command
    await self.matter_client.send_device_command(
    ...<3 lines>...
    )
  File "/usr/local/lib/python3.13/site-packages/matter_server/client/client.py", line 460, in send_device_command
    return await self.send_command(
           ^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/matter_server/client/client.py", line 587, in send_command
    await self.connection.send_message(message)
  File "/usr/local/lib/python3.13/site-packages/matter_server/client/connection.py", line 159, in send_message
    await self._ws_client.send_json(message, dumps=json_dumps)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client_ws.py", line 259, in send_json
    await self.send_str(dumps(data), compress=compress)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client_ws.py", line 243, in send_str
    await self._writer.send_frame(
        data.encode("utf-8"), WSMsgType.TEXT, compress=compress
    )
  File "/usr/local/lib/python3.13/site-packages/aiohttp/_websocket/writer.py", line 125, in send_frame
    raise ClientConnectionResetError("Cannot write to closing transport")
aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport
2025-01-25 04:05:53.420 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall light.turn_on (c:01JJDT68CK:al:JZUW:ntrv:SA): entity_id=['light.kitchen_fridge_nightlight'], params=brightness=86, color_temp=500, color_temp_kelvin=2000>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 2815, in _run_service_call_catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 2838, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/hass_utils.py", line 62, in service_func_proxy
    await existing_service.job.target(call)
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1006, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
        hass, entity, func, data, call.context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1078, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 644, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 313, in async_turn_on
    await self._set_color_temp(color_temp_kelvin, transition)
  File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 146, in _set_color_temp
    await self.send_device_command(
    ...<9 lines>...
    )
  File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 287, in send_device_command
    await self.matter_client.send_device_command(
    ...<3 lines>...
    )
  File "/usr/local/lib/python3.13/site-packages/matter_server/client/client.py", line 460, in send_device_command
    return await self.send_command(
           ^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/matter_server/client/client.py", line 587, in send_command
    await self.connection.send_message(message)
  File "/usr/local/lib/python3.13/site-packages/matter_server/client/connection.py", line 159, in send_message
    await self._ws_client.send_json(message, dumps=json_dumps)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client_ws.py", line 259, in send_json
    await self.send_str(dumps(data), compress=compress)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client_ws.py", line 243, in send_str
    await self._writer.send_frame(
        data.encode("utf-8"), WSMsgType.TEXT, compress=compress
    )
  File "/usr/local/lib/python3.13/site-packages/aiohttp/_websocket/writer.py", line 125, in send_frame
    raise ClientConnectionResetError("Cannot write to closing transport")
aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport
2025-01-25 04:05:53.425 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall light.turn_on (c:01JJDT68CK:al:JZUW:ntrv:SA): entity_id=['light.living_room_nightlight'], params=brightness=86, color_temp=500, color_temp_kelvin=2000>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 2815, in _run_service_call_catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 2838, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/hass_utils.py", line 62, in service_func_proxy
    await existing_service.job.target(call)
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1006, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
        hass, entity, func, data, call.context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1078, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 644, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 313, in async_turn_on
    await self._set_color_temp(color_temp_kelvin, transition)
  File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 146, in _set_color_temp
    await self.send_device_command(
    ...<9 lines>...
    )
  File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 287, in send_device_command
    await self.matter_client.send_device_command(
    ...<3 lines>...
    )
  File "/usr/local/lib/python3.13/site-packages/matter_server/client/client.py", line 460, in send_device_command
    return await self.send_command(
           ^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/matter_server/client/client.py", line 587, in send_command
    await self.connection.send_message(message)
  File "/usr/local/lib/python3.13/site-packages/matter_server/client/connection.py", line 159, in send_message
    await self._ws_client.send_json(message, dumps=json_dumps)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client_ws.py", line 259, in send_json
    await self.send_str(dumps(data), compress=compress)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client_ws.py", line 243, in send_str
    await self._writer.send_frame(
        data.encode("utf-8"), WSMsgType.TEXT, compress=compress
    )
  File "/usr/local/lib/python3.13/site-packages/aiohttp/_websocket/writer.py", line 125, in send_frame
    raise ClientConnectionResetError("Cannot write to closing transport")
aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport
2025-01-25 04:05:53.430 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall light.turn_on (c:01JJDT68CK:al:JZUW:ntrv:SA): entity_id=['light.master_bedroom_zac_nightlight'], params=brightness=86, color_temp=500, color_temp_kelvin=2000>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 2815, in _run_service_call_catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 2838, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/hass_utils.py", line 62, in service_func_proxy
    await existing_service.job.target(call)
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1006, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
        hass, entity, func, data, call.context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1078, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 644, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 313, in async_turn_on
    await self._set_color_temp(color_temp_kelvin, transition)
  File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 146, in _set_color_temp
    await self.send_device_command(
    ...<9 lines>...
    )
  File "/usr/src/homeassistant/homeassistant/components/matter/light.py", line 287, in send_device_command
    await self.matter_client.send_device_command(
    ...<3 lines>...
    )
  File "/usr/local/lib/python3.13/site-packages/matter_server/client/client.py", line 460, in send_device_command
    return await self.send_command(
           ^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/matter_server/client/client.py", line 587, in send_command
    await self.connection.send_message(message)
  File "/usr/local/lib/python3.13/site-packages/matter_server/client/connection.py", line 159, in send_message
    await self._ws_client.send_json(message, dumps=json_dumps)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client_ws.py", line 259, in send_json
    await self.send_str(dumps(data), compress=compress)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client_ws.py", line 243, in send_str
    await self._writer.send_frame(
        data.encode("utf-8"), WSMsgType.TEXT, compress=compress
    )
  File "/usr/local/lib/python3.13/site-packages/aiohttp/_websocket/writer.py", line 125, in send_frame
    raise ClientConnectionResetError("Cannot write to closing transport")
aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport
2025-01-25 04:05:53.434 WARNING (MainThread) [aioesphomeapi.connection] gl-s10-bt-proxy-6802bc @ 192.168.2.33: Connection error occurred: [Errno 32] Broken pipe
2025-01-25 04:05:53.533 WARNING (MainThread) [aioesphomeapi.connection] gl-s10-bt-proxy-cfa6d4 @ 192.168.2.61: Connection error occurred: gl-s10-bt-proxy-cfa6d4 @ 192.168.2.61: EOF received
2025-01-25 04:05:53.535 WARNING (MainThread) [aioesphomeapi.connection] gl-s10-bt-proxy-67f5dc @ 192.168.2.206: Connection error occurred: gl-s10-bt-proxy-67f5dc @ 192.168.2.206: EOF received
2025-01-25 04:05:53.537 WARNING (MainThread) [aioesphomeapi.connection] gl-s10-bt-proxy-a25748 @ 192.168.2.115: Connection error occurred: gl-s10-bt-proxy-a25748 @ 192.168.2.115: EOF received
2025-01-25 04:05:53.541 WARNING (MainThread) [aioesphomeapi.connection] gl-s10-bt-proxy-67f8f4 @ 192.168.2.68: Connection error occurred: gl-s10-bt-proxy-67f8f4 @ 192.168.2.68: EOF received
2025-01-25 04:05:53.543 WARNING (MainThread) [aioesphomeapi.connection] gl-s10-bt-proxy-cfb3dc @ 192.168.2.31: Connection error occurred: gl-s10-bt-proxy-cfb3dc @ 192.168.2.31: EOF received
2025-01-25 04:05:53.545 WARNING (MainThread) [aioesphomeapi.connection] esp32-bluetooth-proxy-bcfae0 @ 192.168.2.52: Connection error occurred: esp32-bluetooth-proxy-bcfae0 @ 192.168.2.52: EOF received
2025-01-25 04:05:53.553 WARNING (MainThread) [aioesphomeapi.connection] boys_room_purifier @ 192.168.2.74: Connection error occurred: boys_room_purifier @ 192.168.2.74: EOF received
2025-01-25 04:05:53.570 WARNING (MainThread) [aioesphomeapi.connection] master_bedroom_purifier @ 192.168.2.237: Connection error occurred: master_bedroom_purifier @ 192.168.2.237: EOF received
2025-01-25 04:05:53.576 WARNING (MainThread) [aioesphomeapi.connection] localdeck-426b08 @ 192.168.2.203: Connection error occurred: localdeck-426b08 @ 192.168.2.203: EOF received
2025-01-25 04:05:53.593 WARNING (MainThread) [aioesphomeapi.connection] esp32-bluetooth-proxy-frontdoor @ 192.168.2.106: Connection error occurred: esp32-bluetooth-proxy-frontdoor @ 192.168.2.106: EOF received
2025-01-25 04:06:13.621 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall light.turn_on (c:01JJDT68CY:al:IFSG:ntrv:QJ): entity_id=['light.master_bedroom_bed_underlights'], params=transition=45.0, brightness=124, color_temp=500, color_temp_kelvin=2000>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/hue/bridge.py", line 128, in async_request_call
    return await task(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohue/v2/controllers/lights.py", line 102, in set_state
    await self.update(id, update_obj)
  File "/usr/local/lib/python3.13/site-packages/aiohue/v2/controllers/base.py", line 158, in update
    await self._bridge.request("put", endpoint, json=data)
  File "/usr/local/lib/python3.13/site-packages/aiohue/v2/__init__.py", line 168, in request
    async with self.create_request(method, path, **kwargs) as resp:
               ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/contextlib.py", line 214, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohue/v2/__init__.py", line 213, in create_request
    async with self._websession.request(method, url, **kwargs) as res:
               ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 1425, in __aenter__
    self._resp: _RetType = await self._coro
                           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 728, in _request
    resp = await req.send(conn)
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client_reqrep.py", line 752, in send
    await writer.write_headers(status_line, self.headers)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/http_writer.py", line 152, in write_headers
    self._write(buf)
    ~~~~~~~~~~~^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/http_writer.py", line 81, in _write
    raise ClientConnectionResetError("Cannot write to closing transport")
aiohttp.client_exceptions.ClientConnectionResetError: Cannot write to closing transport

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 2815, in _run_service_call_catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 2838, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/hass_utils.py", line 62, in service_func_proxy
    await existing_service.job.target(call)
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1006, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
        hass, entity, func, data, call.context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1078, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 644, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/hue/v2/light.py", line 260, in async_turn_on
    await self.bridge.async_request_call(
    ...<8 lines>...
    )
  File "/usr/src/homeassistant/homeassistant/components/hue/bridge.py", line 139, in async_request_call
    raise HomeAssistantError(
        f"Request failed due connection error: {err}"
    ) from err
homeassistant.exceptions.HomeAssistantError: Request failed due connection error: Cannot write to closing transport
2025-01-25 04:06:15.965 WARNING (MainThread) [homeassistant.components.media_player] Updating denonavr media_player took longer than the scheduled update interval 0:00:10
2025-01-25 04:06:15.966 WARNING (MainThread) [homeassistant.components.switch] Updating adguard switch took longer than the scheduled update interval 0:00:10
2025-01-25 04:06:15.967 WARNING (MainThread) [homeassistant.components.switch] Updating adguard switch took longer than the scheduled update interval 0:00:10
2025-01-25 04:06:16.096 ERROR (MainThread) [custom_components.wattbox] Could not update data - 
2025-01-25 04:06:16.602 ERROR (MainThread) [homeassistant.components.teslemetry] Error requesting Teslemetry Energy Site Info data: Cannot connect to host na.teslemetry.com:443 ssl:default [None]
2025-01-25 04:06:16.663 ERROR (MainThread) [custom_components.wattbox] Could not update data - 
2025-01-25 04:06:16.663 ERROR (MainThread) [custom_components.wattbox] Could not update data - 
2025-01-25 04:06:16.664 ERROR (MainThread) [custom_components.wattbox] Could not update data - 
2025-01-25 04:06:16.664 ERROR (MainThread) [custom_components.wattbox] Could not update data - 
2025-01-25 04:06:16.664 ERROR (MainThread) [custom_components.wattbox] Could not update data - 
2025-01-25 04:06:16.664 ERROR (MainThread) [custom_components.wattbox] Could not update data - 
2025-01-25 04:06:16.891 ERROR (MainThread) [homeassistant.components.smlight] Error fetching smlight_192.168.2.38 data: Connection failed
2025-01-25 04:06:17.031 ERROR (MainThread) [homeassistant.components.teslemetry] Error requesting Teslemetry Energy History 2252374244182965 data: Cannot connect to host na.teslemetry.com:443 ssl:default [None]
2025-01-25 04:06:17.031 ERROR (MainThread) [homeassistant.components.spotify.coordinator] Error requesting spotify data: Cannot connect to host accounts.spotify.com:443 ssl:default [None]
2025-01-25 04:06:17.734 ERROR (MainThread) [custom_components.purpleair.PurpleAirApi] Unable to connect to purple air device: http://192.168.3.199/json?live=false
2025-01-25 04:06:17.866 WARNING (MainThread) [homeassistant.components.websocket_api.http.connection] [140405615552848] from 192.168.2.132 (Mozilla/5.0 (iPad; CPU OS 15_8_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Kiosker Pro/22.23.1): Disconnected: Did not receive auth message within 10 seconds
2025-01-25 04:06:18.251 WARNING (MainThread) [homeassistant.components.sensor] Updating slack sensor took longer than the scheduled update interval 0:00:30
2025-01-25 04:06:21.091 ERROR (MainThread) [homeassistant.components.teslemetry] Error requesting Teslemetry Energy Site Live data: Cannot connect to host na.teslemetry.com:443 ssl:default [None]
2025-01-25 04:06:22.529 ERROR (MainThread) [coap-server] Shutdown timeout exceeded, returning anyway. Interfaces still busy: {<Task pending name='Shutdown of <TokenManager for <aiocoap.transports.ws.WSPool object at 0x7fb21bd41950>>' coro=<TokenManager.shutdown() running at /usr/local/lib/python3.13/site-packages/aiocoap/tokenmanager.py:65> wait_for=<Future pending cb=[Task.task_wakeup()]>>}
2025-01-25 04:06:28.411 ERROR (MainThread) [custom_components.wattbox] Could not update data - 
2025-01-25 04:06:33.929 WARNING (MainThread) [homeassistant.components.media_player] Updating denonavr media_player took longer than the scheduled update interval 0:00:10
2025-01-25 04:06:33.931 WARNING (MainThread) [homeassistant.components.switch] Updating adguard switch took longer than the scheduled update interval 0:00:10
2025-01-25 04:06:33.931 WARNING (MainThread) [homeassistant.components.switch] Updating adguard switch took longer than the scheduled update interval 0:00:10
2025-01-25 04:06:35.053 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/zigpy_znp/api.py", line 1112, in request_callback_rsp
    await self.request(request, timeout=timeout, **response_params)
  File "/usr/local/lib/python3.13/site-packages/zigpy_znp/api.py", line 1073, in request
    response = await response_future
               ^^^^^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/zigpy_znp/api.py", line 1111, in request_callback_rsp
    async with async_timeout.timeout(timeout):
               ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/async_timeout/__init__.py", line 141, in __aexit__
    self._do_exit(exc_type)
    ~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/async_timeout/__init__.py", line 228, in _do_exit
    raise asyncio.TimeoutError
TimeoutError
2025-01-25 04:06:35.103 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/zigpy_znp/api.py", line 1112, in request_callback_rsp
    await self.request(request, timeout=timeout, **response_params)
  File "/usr/local/lib/python3.13/site-packages/zigpy_znp/api.py", line 1047, in request
    async with ctx:
               ^^^
  File "/usr/local/lib/python3.13/site-packages/zigpy/datastructures.py", line 23, in __aenter__
    await self.on_enter()
  File "/usr/local/lib/python3.13/site-packages/zigpy/datastructures.py", line 132, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/zigpy_znp/api.py", line 1111, in request_callback_rsp
    async with async_timeout.timeout(timeout):
               ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/async_timeout/__init__.py", line 141, in __aexit__
    self._do_exit(exc_type)
    ~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/async_timeout/__init__.py", line 228, in _do_exit
    raise asyncio.TimeoutError
TimeoutError
2025-01-25 04:06:35.549 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/zigpy_znp/api.py", line 1112, in request_callback_rsp
    await self.request(request, timeout=timeout, **response_params)
  File "/usr/local/lib/python3.13/site-packages/zigpy_znp/api.py", line 1047, in request
    async with ctx:
               ^^^
  File "/usr/local/lib/python3.13/site-packages/zigpy/datastructures.py", line 23, in __aenter__
    await self.on_enter()
  File "/usr/local/lib/python3.13/site-packages/zigpy/datastructures.py", line 132, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/zigpy_znp/api.py", line 1111, in request_callback_rsp
    async with async_timeout.timeout(timeout):
               ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/async_timeout/__init__.py", line 141, in __aexit__
    self._do_exit(exc_type)
    ~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/async_timeout/__init__.py", line 228, in _do_exit
    raise asyncio.TimeoutError
TimeoutError
2025-01-25 04:06:35.686 WARNING (MainThread) [homeassistant.components.sonos.speaker] Subscription renewal failed for Back Deck: Request timed out
2025-01-25 04:06:35.691 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/zigpy_znp/api.py", line 1112, in request_callback_rsp
    await self.request(request, timeout=timeout, **response_params)
  File "/usr/local/lib/python3.13/site-packages/zigpy_znp/api.py", line 1047, in request
    async with ctx:
               ^^^
  File "/usr/local/lib/python3.13/site-packages/zigpy/datastructures.py", line 23, in __aenter__
    await self.on_enter()
  File "/usr/local/lib/python3.13/site-packages/zigpy/datastructures.py", line 132, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/zigpy_znp/api.py", line 1111, in request_callback_rsp
    async with async_timeout.timeout(timeout):
               ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/async_timeout/__init__.py", line 141, in __aexit__
    self._do_exit(exc_type)
    ~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/async_timeout/__init__.py", line 228, in _do_exit
    raise asyncio.TimeoutError
TimeoutError
2025-01-25 04:06:35.692 WARNING (MainThread) [homeassistant.components.mqtt.client] No ACK from MQTT server in 10 seconds (mid: 145)
2025-01-25 04:06:35.769 ERROR (MainThread) [custom_components.wattbox] Could not update data - 
2025-01-25 04:06:36.081 ERROR (MainThread) [homeassistant.components.roborock.coordinator] Error fetching roborock data: id=27395 Timeout after 4 seconds
2025-01-25 04:06:36.663 ERROR (MainThread) [homeassistant.components.spotify] Error requesting Spotify Devices data: Cannot connect to host accounts.spotify.com:443 ssl:default [None]
2025-01-25 04:06:36.896 ERROR (MainThread) [custom_components.purpleair.PurpleAirApi] Unable to connect to purple air device: http://192.168.3.199/json?live=false

Additional information

No response

About this issue

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

Most upvoted comments

If you can get a py-spy when this is happening, we should be able to get a better idea about what is going on https://community.home-assistant.io/t/instructions-to-install-py-spy-on-haos/480473

Alternatively, if the system is responding enough to start the profiler, a profile from the profiler.start service may be enough https://www.home-assistant.io/integrations/profiler/

Usually for cases like this, we see some integration creating too many small tasks where the task overhead is higher than the cost of running the task which overloads the event loop. However we can’t know for sure without a profile or py-spy

Yes, that’s the goal, however, you want to minimize the runtime as much as possible, as the longer the profile runs, the harder it is to see a problem because the amount of data it gathers is so large, that you end up looking for a needle and a haystack