Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unifi Websocket disconnect error: %s #118167

Closed
brinkgit opened this issue May 26, 2024 · 3 comments
Closed

Unifi Websocket disconnect error: %s #118167

brinkgit opened this issue May 26, 2024 · 3 comments

Comments

@brinkgit
Copy link

brinkgit commented May 26, 2024

The problem

Since a week or so, the error shows up every now and then. The unifi devices are getting unavialable, mostly for a couple of seconds, sometimes longer (up to several mnutes this morning).
Mostly the devices get available by itself, but this morning I had to restart the integration to activate the cloud key gen 2 plus

What version of Home Assistant Core has the issue?

core-2024.5.3

What was the last working version of Home Assistant Core?

core-2024.5.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

unifi protect

Link to integration documentation on our website

No response

Diagnostics information

Logger: pyunifiprotect.websocket
Bron: /usr/local/lib/python3.12/site-packages/pyunifiprotect/websocket.py:108
Eerst voorgekomen: 12:16:18 (1 gebeurtenissen)
Laatst gelogd: 12:16:18

Websocket disconnect error: %s
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1025, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1120, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1102, in create_connection
sock = await self._connect_sock(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1005, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect
return await fut
^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('10.0.0.111', 443)

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

Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/websocket.py", line 95, in _websocket_loop
self._ws_connection = await session.ws_connect(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 835, in _ws_connect
resp = await self.request(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 581, in _request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 944, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1257, in _create_direct_connection
raise last_exc
File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1226, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1033, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 10.0.0.111:443 ssl:False [Connect call failed ('10.0.0.111', 443)]

At the same time the next error come up:

Logger: homeassistant.components.unifiprotect.data
Bron: components/unifiprotect/data.py:133
integratie: UniFi Protect (documentatie, problemen)
Eerst voorgekomen: 12:16:21 (3 gebeurtenissen)
Laatst gelogd: 13:24:19

Error while updating
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1025, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1120, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1102, in create_connection
sock = await self._connect_sock(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1005, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect
return await fut
^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('10.0.0.111', 443)

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

Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/api.py", line 311, in request
response = await req_context.aenter() # noqa: PLC2801
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1197, in aenter
self._resp = await self._coro
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 581, in _request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 944, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1257, in _create_direct_connection
raise last_exc
File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1226, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1033, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 10.0.0.111:443 ssl:False [Connect call failed ('10.0.0.111', 443)]

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

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/unifiprotect/data.py", line 133, in async_refresh
updates = await self.api.update(force=force)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/api.py", line 810, in update
events = await self.get_events(
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/api.py", line 1058, in get_events
response = await self.get_events_raw(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/api.py", line 997, in get_events_raw
events = await self._get_event_paginate(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/api.py", line 891, in _get_event_paginate
new_events = await self.api_request_list("events", params=params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/api.py", line 439, in api_request_list
data = await self.api_request(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/api.py", line 397, in api_request
data = await self.api_request_raw(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/api.py", line 358, in api_request_raw
response = await self.request(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/api.py", line 340, in request
raise NvrError(
pyunifiprotect.exceptions.NvrError: Error requesting data from 10.0.0.111: Cannot connect to host 10.0.0.111:443 ssl:False [Connect call failed ('10.0.0.111', 443)]

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

The unifi protect app does not show a disconnection

@home-assistant
Copy link

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (unifiprotect) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of unifiprotect can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign unifiprotect Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


unifiprotect documentation
unifiprotect source
(message by IssueLinks)

@bdraco bdraco removed their assignment Jun 4, 2024
@bdraco
Copy link
Member

bdraco commented Jun 21, 2024

Frequently we see seemingly random disconnects because the event loop is blocked.

Please try

https://community.home-assistant.io/t/2024-5-tracking-down-instability-issues-caused-by-integrations/724441

Using Home Assistant's built-in debug mode in 2024.5.x or later (preferred)

and

Enabling asyncio debug mode at run time (preferred)

@bdraco
Copy link
Member

bdraco commented Jun 22, 2024

fixed via #120173 in 2024.7.x

@bdraco bdraco closed this as completed Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants