dahua icon indicating copy to clipboard operation
dahua copied to clipboard

Error custom_components/dahua/client.py:744

Open Lhopes1 opened this issue 5 months ago • 12 comments

Good morning, I'm receiving this error on my HA. How can I resolve it?

This error originated from a custom integration.

Registration: custom_components.dahua Source: custom_components/dahua/client.py:744 Integration: Dahua (documentation, issues) First occurrence: 12:18:12 (21 occurrences) Last record: 12:28:20

Traceback (most recent call last): File "/usr/local/lib/python3.13/site-packages/aiohttp/streams.py", line 347, in _wait await waiter asyncio.exceptions.CancelledError

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

Traceback (most recent call last): File "/config/custom_components/dahua/client.py", line 744, in stream_events async for data, _ in response.content.iter_chunks(): on_receive(data, channel) File "/usr/local/lib/python3.13/site-packages/aiohttp/streams.py", line 71, in anext rv = await self._stream.readchunk() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.13/site-packages/aiohttp/streams.py", line 476, in readchunk await self._wait("readchunk") File "/usr/local/lib/python3.13/site-packages/aiohttp/streams.py", line 346, in _wait with self._timer: ^^^^^^^^^^^ File "/usr/local/lib/python3.13/site-packages/aiohttp/helpers.py", line 685, in exit raise asyncio.TimeoutError from exc_val TimeoutError

Lhopes1 avatar Aug 11 '25 11:08 Lhopes1

First occurred: July 25, 2025 at 14:33:06 (13216 occurrences)
Last logged: 15:16:27

I would like to keep using this integration, but that's getting out of hand a bit

nazgee avatar Aug 17 '25 13:08 nazgee

I am having something similar. Have you managed to fix it? My log file is full of these messages:

TimeoutError 2025-09-04 15:02:38.080 ERROR (MainThread) [custom_components.dahua] Traceback (most recent call last): File "/usr/local/lib/python3.13/site-packages/aiohttp/streams.py", line 347, in _wait await waiter asyncio.exceptions.CancelledError

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

Traceback (most recent call last): File "/config/custom_components/dahua/client.py", line 744, in stream_events async for data, _ in response.content.iter_chunks(): on_receive(data, channel) File "/usr/local/lib/python3.13/site-packages/aiohttp/streams.py", line 71, in anext rv = await self._stream.readchunk() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.13/site-packages/aiohttp/streams.py", line 476, in readchunk await self._wait("readchunk") File "/usr/local/lib/python3.13/site-packages/aiohttp/streams.py", line 346, in _wait with self._timer: ^^^^^^^^^^^ File "/usr/local/lib/python3.13/site-packages/aiohttp/helpers.py", line 685, in exit raise asyncio.TimeoutError from exc_val

Rokite66 avatar Sep 04 '25 13:09 Rokite66

I found this as a workaround (credit goes to peterdelios):

if you want to suppress the errors in the new version just replace this back again in client.py

except Exception as exception:
    pass

from what is there in new version

except Exception as exception:
    _LOGGER.exception(exception)

Rokite66 avatar Sep 04 '25 13:09 Rokite66

Good afternoon, I still haven't resolved it and I ended up removing the integration. I use webRTC camera plus go2rtc to view it on the panel. Unfortunately, the Dahua integration presents many errors and the motion sensors don't work correctly. In my case, peterdelios solution didn't resolve the issue, the errors don't disappear. I'll wait until they can resolve these integration errors, as I believe there are more people in the same situation.

Lhopes1 avatar Sep 04 '25 14:09 Lhopes1

In my case the errors are gone. Did you restart home assistant after the modification?

Rokite66 avatar Sep 05 '25 13:09 Rokite66

In my case the errors are gone. Did you restart home assistant after the modification?

Yes, I did that, but the errors still appear, and do your sensors work well? Below is the code snippet. Can you check if yours is like that too?

            try:
            auth = DigestAuth(self._username, self._password, self._session)
            response = await auth.request("GET", url)
            response.raise_for_status()

            # https://docs.aiohttp.org/en/stable/streams.html
            async for data, _ in response.content.iter_chunks():
                on_receive(data, channel)
        except Exception as exception:
            _LOGGER.exception(exception)
        finally:
            if response is not None:
                response.close()

Lhopes1 avatar Sep 05 '25 14:09 Lhopes1

If it's not too much trouble, could you send me the complete file with this change so I can test it on my HA? Thank you in advance.

Lhopes1 avatar Sep 05 '25 14:09 Lhopes1

client.py

Rokite66 avatar Sep 05 '25 15:09 Rokite66

I don't use sensors but I can check if you tell me what sensors to look for.

Image

Rokite66 avatar Sep 05 '25 15:09 Rokite66

Wow, I think that's it, I've already managed to install it and it seems that the errors have disappeared, when you come to Portugal let me know, I'll buy you a beer!!, thank you very much!

Lhopes1 avatar Sep 05 '25 16:09 Lhopes1

Happy to help! Portugal sounds like a nice country to visit (have only been to Porto). Would like to go kitesurfing there one day.

Rokite66 avatar Sep 05 '25 17:09 Rokite66

@Rokite66 - many thanks for your file! Works as expected and no more errors! Really appreciate!

DeveloperSzkodziu avatar Sep 09 '25 12:09 DeveloperSzkodziu