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

trace backs on what look like basic connection error #161

Open
bagobones opened this issue Feb 12, 2022 · 7 comments
Open

trace backs on what look like basic connection error #161

bagobones opened this issue Feb 12, 2022 · 7 comments

Comments

@bagobones
Copy link

bagobones commented Feb 12, 2022

Version of the custom_component

0.9.36

Logs

2022-02-12 23:35:50 WARNING (MainThread) [custom_components.dahua] Failed to sync device state
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect
    return await fut
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.103.8', 80)

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

Traceback (most recent call last):
  File "/config/custom_components/dahua/__init__.py", line 279, in _async_update_data
    results = await asyncio.gather(*coros)
  File "/config/custom_components/dahua/client.py", line 187, in async_get_config_lighting
    return await self.async_get_config("Lighting[{0}][{1}]".format(channel, profile_mode))
  File "/config/custom_components/dahua/client.py", line 172, in async_get_config
    return await self.get(url)
  File "/config/custom_components/dahua/client.py", line 675, in get
    raise exception
  File "/config/custom_components/dahua/client.py", line 660, in get
    response = await auth.request("GET", url)
  File "/config/custom_components/dahua/digest.py", line 46, in request
    response = await self.session.request(method, url, headers=headers, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.103.8:80 ssl:default [Connect call failed ('192.168.103.8', 80)]

Describe the bug

AD110 is slow and sometimes drops off WiFi if it roams APs etc.. This looks like a simple connection failure causes a unstrapped error.

@rroller
Copy link
Owner

rroller commented Feb 13, 2022

Does this put the integration into an unusable state after this happens?

@rroller
Copy link
Owner

rroller commented Feb 13, 2022

Wifi will have these issues and these are very low powered devices so connection issues aren't uncommon. I setup mine and haven't seen this.

@bagobones
Copy link
Author

bagobones commented Feb 13, 2022

Main issue here is that this is filling my Home assistant log with Tracebacks instead of maybe a trapped graceful Lost connection warning or something.. which seems recent..

The doorbell is on the edge of my wifi coverage even with me putting a meshed AP closer too it..

  1. If this is due to time out of a call maybe it could be configurable?
  2. It seems to recover and still function, if this is error should be trapped and ignored or spit out a less verbose error or warn that could be potentially filtered.. It seems to be growing my HA log a lot as the stand out error.

I have rebooted the cam and will see if I can get better wifi performance.. I live in a fairly congested wifi area and the AD110 is 2.4Ghz only so it is fairly common for a close by neighbours AP to auto switch channels and cause interference.

@rroller
Copy link
Owner

rroller commented Feb 13, 2022

Got it. I will only log a single line going forward but log the full stack trace as a debug log. Those who want the full stack trace can enable debug logs if they need it.

@rroller
Copy link
Owner

rroller commented Feb 13, 2022

Logging updated in https://github.com/rroller/dahua/releases/tag/0.9.37

Please try that

@bagobones
Copy link
Author

Sounds like a good solution. Will test it out when I get a chance.

@bagobones
Copy link
Author

Got the following after rebooting and letting it run for a few hours..

2022-02-14 03:03:33 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration dahua 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
2022-02-14 03:03:33 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration hacs 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
2022-02-14 03:07:46 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, 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 98, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 79, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 219, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 753, in get
    return await self.handle(request, camera)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 771, in handle
    image = await _async_get_image(
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 169, in _async_get_image
    image_bytes = await camera.async_camera_image(
  File "/config/custom_components/dahua/camera.py", line 233, in async_camera_image
    return await self._coordinator.client.async_get_snapshot(self._channel_number)
  File "/config/custom_components/dahua/client.py", line 66, in async_get_snapshot
    return await self.get_bytes(url)
  File "/config/custom_components/dahua/client.py", line 654, in get_bytes
    response.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://192.168.103.8:80/cgi-bin/snapshot.cgi?channel=1')
2022-02-14 03:23:27 ERROR (MainThread) [homeassistant.components.homekit.type_cameras] Camera has no stream source
2022-02-14 03:23:27 ERROR (MainThread) [pyhap.camera] [ca6e9f52-3dc2-4f1e-a030-dfb546e26841] Failed to start/reconfigure stream, deleting session.
2022-02-14 03:23:57 ERROR (MainThread) [pyhap.camera] Requested to stop stream for session ca6e9f52-3dc2-4f1e-a030-dfb546e26841, but no such session was found
2022-02-14 03:42:54 ERROR (MainThread) [homeassistant.components.homekit.type_cameras] Camera has no stream source
2022-02-14 03:42:54 ERROR (MainThread) [pyhap.camera] [c801a1f8-a43e-4d0a-a2c1-dde0cb3dbcc3] Failed to start/reconfigure stream, deleting session.
2022-02-14 03:43:06 ERROR (MainThread) [pyhap.camera] Requested to stop stream for session c801a1f8-a43e-4d0a-a2c1-dde0cb3dbcc3, but no such session was found
2022-02-14 03:54:57 WARNING (MainThread) [homeassistant.components.automation.doods_doorbell] Doods: Doorbell  Person Scan Events: Already running
2022-02-14 04:21:21 ERROR (MainThread) [homeassistant.components.homekit.type_cameras] Camera has no stream source
2022-02-14 04:21:21 ERROR (MainThread) [pyhap.camera] [8b840c05-a65a-4505-ada0-5e262efe31fc] Failed to start/reconfigure stream, deleting session.
2022-02-14 04:21:21 ERROR (MainThread) [homeassistant.components.homekit.type_cameras] Camera has no stream source
2022-02-14 04:21:21 ERROR (MainThread) [pyhap.camera] [a74392f4-da3c-4232-8979-e22d5198782d] Failed to start/reconfigure stream, deleting session.
2022-02-14 04:21:41 WARNING (MainThread) [homeassistant.components.automation.doods_doorbell] Doods: Doorbell  Person Scan Events: Already running
2022-02-14 04:21:51 ERROR (MainThread) [pyhap.camera] Requested to stop stream for session 8b840c05-a65a-4505-ada0-5e262efe31fc, but no such session was found
2022-02-14 04:21:51 ERROR (MainThread) [pyhap.camera] Requested to stop stream for session a74392f4-da3c-4232-8979-e22d5198782d, but no such session was found
2022-02-14 04:24:02 ERROR (MainThread) [homeassistant.components.homekit.type_cameras] Camera has no stream source
2022-02-14 04:24:02 ERROR (MainThread) [pyhap.camera] [00c2f65e-d115-46f8-944d-88f6be922b14] Failed to start/reconfigure stream, deleting session.
2022-02-14 04:24:02 ERROR (MainThread) [homeassistant.components.homekit.type_cameras] Camera has no stream source
2022-02-14 04:24:02 ERROR (MainThread) [pyhap.camera] [92d9ee51-6e61-4d11-8fb9-94317e46e04a] Failed to start/reconfigure stream, deleting session.
2022-02-14 04:24:33 ERROR (MainThread) [pyhap.camera] Requested to stop stream for session 00c2f65e-d115-46f8-944d-88f6be922b14, but no such session was found
2022-02-14 04:24:33 ERROR (MainThread) [pyhap.camera] Requested to stop stream for session 92d9ee51-6e61-4d11-8fb9-94317e46e04a, but no such session was found
2022-02-14 04:30:12 ERROR (MainThread) [homeassistant.components.homekit.type_cameras] Camera has no stream source
2022-02-14 04:30:12 ERROR (MainThread) [pyhap.camera] [213ca0b9-53aa-46b9-94b1-620846748822] Failed to start/reconfigure stream, deleting session.
2022-02-14 04:30:12 ERROR (MainThread) [homeassistant.components.homekit.type_cameras] Camera has no stream source
2022-02-14 04:30:12 ERROR (MainThread) [pyhap.camera] [f51807df-39a8-4c2c-ac6e-7aecd5ee59a1] Failed to start/reconfigure stream, deleting session.
2022-02-14 04:30:29 ERROR (MainThread) [pyhap.camera] Requested to stop stream for session 213ca0b9-53aa-46b9-94b1-620846748822, but no such session was found
2022-02-14 04:30:42 ERROR (MainThread) [pyhap.camera] Requested to stop stream for session f51807df-39a8-4c2c-ac6e-7aecd5ee59a1, but no such session was found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants