Help please - homeassistant.components.websocket_api.http.connection - Connection closed by client

I have a problem with my Home Assistant, where, after a period of time (could be minutes, hours or days after a restart of HA) I get the following error, various integrations seem to fail to get data, and my dashboards (which run HomeHabit) all fail to get new data/camera streams etc.

2020-04-18 13:37:16 INFO (MainThread) [homeassistant.components.websocket_api.http.connection.4527698368] Connection closed by client
2020-04-18 13:38:40 INFO (MainThread) [homeassistant.components.websocket_api.http.connection.4526058032] Connection closed by client

The failure can go on until a reboot, or fix it self after a while, but once its happened once it seems to keep happening regularly. Is there anything obvious it could be please?

Strange question, but I assume HA is stable for most people? I have never managed to get it to stay up issue free for more than say 2 days (and often much less), without hitting a breaking issue requiring a restart of ha or often the whole box. I run on a mac - is that rare? Im using 0.108.0 (after backdating from 0.108.3 after even more regular issues) is that too new? I love HA, but I need it to just work, for weeks, months or longer, not hours.

I keep removing integrations in the hope of finding a dodgy one, but its still failing often:

config:


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Text to speech
#tts:
#  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
switch: !include switches.yaml

hive:
  username: [email protected]
  password: !secret hive_password
  scan_interval: 1

#roku:
#  - host: 192.168.1.3

camera:
  - platform: foscam
    ip: 192.168.1.191
    port: 88
    username: !secret foscam_username
    password: !secret camera_password
    name: Charlie
  - platform: foscam
    ip: 192.168.1.183
    port: 88
    username: !secret foscam_username
    password: !secret camera_password
    name: Lilly
  - platform: generic
    still_image_url: http://192.168.1.242:80/live/0/jpeg.jpg
    stream_source: rtmp://192.168.1.242:80/live/0/h264.flv
    username: admin
    password: !secret camera_password
    name: FrontDoor

rfxtrx:
  device: /dev/tty.usbserial-A1LQ47X

sensor:
  - platform: rfxtrx
    devices:
      085002054c0400ad79:
        name: Lilly
      08500201460100bf79:
        name: Master Bedroom
      08500202e20100c069:
        name: Charlie
      08500203bd0200c579:
        name: Living Room
      0716029e002e3870:
        name: "Front Door Bell"
        fire_event: true
  - platform: here_travel_time
    name: commute_removed
    api_key: !secret here_apikey
    origin_latitude: "removed"
    origin_longitude: "-removed"
    destination_latitude: "removed"
    destination_longitude: "removed"
    route_mode: fastest
    traffic_mode: true
    unit_system: imperial
  - platform: here_travel_time
    name: commute_removed
    api_key: !secret here_apikey
    origin_latitude: "removed"
    origin_longitude: "-removed"
    destination_latitude: "removed"
    destination_longitude: "removed"
    route_mode: fastest
    traffic_mode: true
    unit_system: imperial

#weather:
#  - platform: openweathermap
#    api_key: 0f9f586bf90145b947154ce3bce095e2
#    mode: freedaily
#    latitude: 50.931483
#    longitude: -1.303895

remote:
#  - platform: harmony
#    name: "Living Room"
#    host: 192.168.1.119
  - platform: harmony
    name: "Cinema Room"
    host: 192.168.1.116

#spotify:
#  client_id: !secret spotify_client_id
#  client_secret: !secret spotify_client_secret

The log messages I see once things have stopped working are like:

2020-04-18 13:53:10 WARNING (MainThread) [homeassistant.helpers.entity] Update of water_heater.hot_water is taking over 10 seconds

and

2020-04-18 13:16:53 ERROR (MainThread) [homeassistant.components.generic.camera] Timeout getting camera image from FrontDoor

I’m not sure there is anything really wrong. The messages at the top aren’t errors they’re just information messages. The only real error is the last one you listed but unclear if that is unrecoverable. Are you seeing something not working or are you just worried about the logs?

Thanks for the reply.
Nothing works - I have 4 dashboards running HomeHabit, and they all stop receiving data. The temperature sensors stop updating. All the camera feeds say connecting but don’t get new images, etc.

Latest theory is the Mac might be power saving in some way.

The problem just happened again.

  • I tried pinging the server, which succeeded, but the issue didnt resolve.
  • I tried loading ip:8123 but it didn’t load.
  • I screen shared onto the server, which allowed me onto the box, and suddenly the dashboards and ip:8123 started responding. The mac has been an always on server for years so I didn’t expect any sleep issues, but it looks pretty likely. Found a few power settings to play with, so have unset anything that might partly sleep the box/hard drive/etc. Waiting to see if this fails again now…

Hmm, 2 of my cameras haven’t started showing the images again :frowning: (Makes me wonder if anything is actually recovered)

Server contains these errors from 5 mins ago:

2020-04-18 16:21:45 WARNING (MainThread) [homeassistant.components.sensor] Updating hive sensor took longer than the scheduled update interval 0:00:30
2020-04-18 16:21:45 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/homeassistant/data_entry_flow.py", line 109, in async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/homeassistant/data_entry_flow.py", line 172, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/homeassistant/helpers/config_entry_oauth2_flow.py", line 271, in async_step_discovery
    return await self.async_step_pick_implementation()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/homeassistant/helpers/config_entry_oauth2_flow.py", line 203, in async_step_pick_implementation
    implementations = await async_get_implementations(self.hass, self.DOMAIN)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/homeassistant/helpers/config_entry_oauth2_flow.py", line 316, in async_get_implementations
    implementation = await get_impl(hass, domain)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/homeassistant/components/cloud/account_link.py", line 29, in async_provide_implementation
    services = await _get_services(hass)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/homeassistant/components/cloud/account_link.py", line 76, in _get_services
    services = await account_link.async_fetch_available_services(hass.data[DOMAIN])
  File "/Users/david/.homeassistant/deps/lib/python/site-packages/hass_nabucasa/account_link.py", line 120, in async_fetch_available_services
    resp = await cloud.client.websession.post(f"{cloud.account_link_url}/services")
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/client.py", line 582, in _request
    break
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/helpers.py", line 586, in __exit__
    raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
2020-04-18 16:22:16 WARNING (MainThread) [homeassistant.components.sensor] Updating hive sensor took longer than the scheduled update interval 0:00:30 

A couple of slightly earlier errors too:

2020-04-18 16:16:50 ERROR (MainThread) [metno] https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/ returned 
2020-04-18 16:16:50 ERROR (MainThread) [homeassistant.components.met.weather] Retrying in 16 minutes
2020-04-18 16:16:55 ERROR (MainThread) [homeassistant.components.updater] Timeout fetching Home Assistant update data

Latest log messages now (16:28) seem to imply most aren’t recovered. (1 camera is def back to showing live pics though strangely):

2020-04-18 16:25:44 WARNING (MainThread) [homeassistant.components.water_heater] Updating hive water_heater took longer than the scheduled update interval 0:01:00
2020-04-18 16:25:44 WARNING (MainThread) [homeassistant.components.climate] Updating hive climate took longer than the scheduled update interval 0:01:00
2020-04-18 16:25:50 WARNING (MainThread) [homeassistant.components.sensor] Updating hive sensor took longer than the scheduled update interval 0:00:30
2020-04-18 16:26:21 WARNING (MainThread) [homeassistant.components.sensor] Updating hive sensor took longer than the scheduled update interval 0:00:30
2020-04-18 16:26:41 WARNING (MainThread) [homeassistant.components.sensor] Updating here_travel_time sensor took longer than the scheduled update interval 0:05:00
2020-04-18 16:26:45 WARNING (MainThread) [homeassistant.components.water_heater] Updating hive water_heater took longer than the scheduled update interval 0:01:00
2020-04-18 16:26:45 WARNING (MainThread) [homeassistant.components.climate] Updating hive climate took longer than the scheduled update interval 0:01:00
2020-04-18 16:26:52 WARNING (MainThread) [homeassistant.components.sensor] Updating hive sensor took longer than the scheduled update interval 0:00:30
2020-04-18 16:27:22 WARNING (MainThread) [homeassistant.components.sensor] Updating hive sensor took longer than the scheduled update interval 0:00:30
2020-04-18 16:27:45 WARNING (MainThread) [homeassistant.components.water_heater] Updating hive water_heater took longer than the scheduled update interval 0:01:00
2020-04-18 16:27:45 WARNING (MainThread) [homeassistant.components.climate] Updating hive climate took longer than the scheduled update interval 0:01:00
2020-04-18 16:27:53 WARNING (MainThread) [homeassistant.components.sensor] Updating hive sensor took longer than the scheduled update interval 0:00:30
2020-04-18 16:28:23 WARNING (MainThread) [homeassistant.components.sensor] Updating hive sensor took longer than the scheduled update interval 

rebooting mac in hope of getting everything back, and giving power saving settings a change to properly work.

So first, I’m not a mac expert. I run HA on a rpi 3b+. I see the warnings for updates taking longer than the allotted time frequently, I don’t think that is a problem. Also I see errors with traceback reports resulting from helpers.py as well. I can’t say for certain but I don’t think that is really an issue. My system is behaving fine. So. I would go with your hunch regarding the power saving mode. Sorry, can’t be more help but likely you know a little more what it isn’t.

Appreciate the reply. Thanks. Really hoping this is effectively user error, not checking that I had disabled every single possible power saving setting, as HA needs more power settings turned off than Plex, SecuritySpy, Dashing, and various other servers I’ve run over the years without issue. Will report back here in a few days, or if it goes wrong before then. :crossed_fingers:

1 Like

So several days later, with every power saving setting I could find turned off on the mac, and we ha has stayed up and running.

Still errors in the logs occasionally, and lots of integrations removed, but the fundamental problem certainly looks to have been the mac power saving. Hopefully this isn’t famous last works…

Now to slowly turn back on various integrations and see how many were only broken by the power saving.