dahua icon indicating copy to clipboard operation
dahua copied to clipboard

RuntimeError: Session is closed

Open luzik opened this issue 2 years ago • 9 comments

This happens to me first time.

Logger: aiohttp.server
Source: custom_components/dahua/digest.py:46
Integration: Dahua ([documentation](https://github.com/rroller/dahua), [issues](https://github.com/rroller/dahua/issues))
First occurred: 12:21:24 (2 occurrences)
Last logged: 12:22:34
Error handling request

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/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 85, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, 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 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 735, in get
    return await self.handle(request, camera)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 753, in handle
    image = await _async_get_image(
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 172, in _async_get_image
    if image_bytes := await camera.async_camera_image(
  File "/config/custom_components/dahua/camera.py", line 243, in async_camera_image
    return await self._coordinator.client.async_get_snapshot(self._channel_number)
  File "/config/custom_components/dahua/client.py", line 74, in async_get_snapshot
    return await self.get_bytes(url)
  File "/config/custom_components/dahua/client.py", line 730, in get_bytes
    response = await auth.request("GET", self._base + 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.10/site-packages/aiohttp/client.py", line 400, in _request
    raise RuntimeError("Session is closed")
RuntimeError: Session is closed

And after that

Exception fetching information from http://192.168.124.30:80/cgi-bin/configManager.cgi?action=getConfig&name=MotionDetect
Exception fetching information from http://192.168.124.30:80/cgi-bin/configManager.cgi?action=getConfig&name=Lighting[0][0]
Exception fetching information from http://192.168.124.30:80/cgi-bin/configManager.cgi?action=getConfig&name=DisableLinkage
Failed to sync device state for 192.168.124.30. See README to enable debug logs to get full exception

Integration manual reload fixed issue, but until reload I wasn't able to open my doors - that was quite a big problem !

Maybe self reload when this exception happens ?

luzik avatar Jun 06 '23 13:06 luzik