maciej-or / hikvision_next

Home Assistant integration for Hikvision NVRs and IP cameras
101 stars 18 forks source link

DVR streams break with auth errors #108

Open maslyankov opened 1 year ago

maslyankov commented 1 year ago

After a few seconds of usage, the camera streams stop working and the integration says Failed to initialize. The DVR is online, I can login and view the streams normally via VLC etc. The issue fixes after I reboot the NVR and re-add it second time, until it happens again shortly.

hikvision_next version: 1.0.10

Logs with enabled debugging:

2023-08-11 13:58:24.779 DEBUG (MainThread) [custom_components.hikvision_next.notifications] Alert: AlertInfo(channel_id=3, io_port_id=0, event_id='motiondetection', device_serial_no='DS-7108HQHI-K10820220422CCWRJ84070785WCVU', mac=None)
2023-08-11 13:58:24.780 DEBUG (MainThread) [custom_components.hikvision_next.notifications] UNIQUE_ID: binary_sensor.ds_7108hqhi_k10820220422ccwrj84070785wcvu_3_motiondetection
2023-08-11 13:58:25.352 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.ds_7108hqhi_k10820220422ccwrj84070785wcvu_301] Error from stream worker: Error opening stream (INVALIDDATA, Invalid data found when processing input) rtsp://****:****@192.168.1.58:554/Streaming/channels/301
2023-08-11 13:58:25.644 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/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 100, 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/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 738, in get
    return await self.handle(request, camera)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 756, 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/hikvision_next/camera.py", line 56, in async_camera_image
    data = await self.isapi.get_camera_image(self.stream_info, width, height)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_next/isapi.py", line 853, in get_camera_image
    image_bytes = b"".join([chunk async for chunk in chunks])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_next/isapi.py", line 853, in <listcomp>
    image_bytes = b"".join([chunk async for chunk in chunks])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/hikvisionapi/hikvisionapi.py", line 289, in opaque_request
    await self._detect_auth_method()
  File "/usr/local/lib/python3.11/site-packages/hikvisionapi/hikvisionapi.py", line 246, in _detect_auth_method
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 749, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'http://192.168.1.58/ISAPI/System/status'
For more information check: https://httpstatuses.com/401
2023-08-11 13:58:25.647 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/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 100, 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/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 738, in get
    return await self.handle(request, camera)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 756, 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/hikvision_next/camera.py", line 56, in async_camera_image
    data = await self.isapi.get_camera_image(self.stream_info, width, height)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_next/isapi.py", line 853, in get_camera_image
    image_bytes = b"".join([chunk async for chunk in chunks])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_next/isapi.py", line 853, in <listcomp>
    image_bytes = b"".join([chunk async for chunk in chunks])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/hikvisionapi/hikvisionapi.py", line 289, in opaque_request
    await self._detect_auth_method()
  File "/usr/local/lib/python3.11/site-packages/hikvisionapi/hikvisionapi.py", line 246, in _detect_auth_method
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 749, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'http://192.168.1.58/ISAPI/System/status'
For more information check: https://httpstatuses.com/401
2023-08-11 13:58:25.651 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/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 100, 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/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 738, in get
    return await self.handle(request, camera)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 756, 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/hikvision_next/camera.py", line 56, in async_camera_image
    data = await self.isapi.get_camera_image(self.stream_info, width, height)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_next/isapi.py", line 853, in get_camera_image
    image_bytes = b"".join([chunk async for chunk in chunks])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_next/isapi.py", line 853, in <listcomp>
    image_bytes = b"".join([chunk async for chunk in chunks])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/hikvisionapi/hikvisionapi.py", line 289, in opaque_request
    await self._detect_auth_method()
  File "/usr/local/lib/python3.11/site-packages/hikvisionapi/hikvisionapi.py", line 246, in _detect_auth_method
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 749, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'http://192.168.1.58/ISAPI/System/status'
For more information check: https://httpstatuses.com/401
2023-08-11 13:58:25.659 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/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 100, 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/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 738, in get
    return await self.handle(request, camera)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 756, 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/hikvision_next/camera.py", line 56, in async_camera_image
    data = await self.isapi.get_camera_image(self.stream_info, width, height)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_next/isapi.py", line 853, in get_camera_image
    image_bytes = b"".join([chunk async for chunk in chunks])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_next/isapi.py", line 853, in <listcomp>
    image_bytes = b"".join([chunk async for chunk in chunks])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/hikvisionapi/hikvisionapi.py", line 289, in opaque_request
    await self._detect_auth_method()
  File "/usr/local/lib/python3.11/site-packages/hikvisionapi/hikvisionapi.py", line 246, in _detect_auth_method
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 749, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'http://192.168.1.58/ISAPI/System/status'
For more information check: https://httpstatuses.com/401
2023-08-11 13:58:25.663 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/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 100, 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/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 738, in get
    return await self.handle(request, camera)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 756, 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/hikvision_next/camera.py", line 56, in async_camera_image
    data = await self.isapi.get_camera_image(self.stream_info, width, height)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_next/isapi.py", line 853, in get_camera_image
    image_bytes = b"".join([chunk async for chunk in chunks])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_next/isapi.py", line 853, in <listcomp>
    image_bytes = b"".join([chunk async for chunk in chunks])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/hikvisionapi/hikvisionapi.py", line 289, in opaque_request
    await self._detect_auth_method()
  File "/usr/local/lib/python3.11/site-packages/hikvisionapi/hikvisionapi.py", line 246, in _detect_auth_method
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 749, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'http://192.168.1.58/ISAPI/System/status'
For more information check: https://httpstatuses.com/401
2023-08-11 13:58:25.666 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/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 100, 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/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 738, in get
    return await self.handle(request, camera)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 756, 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/hikvision_next/camera.py", line 56, in async_camera_image
    data = await self.isapi.get_camera_image(self.stream_info, width, height)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_next/isapi.py", line 853, in get_camera_image
    image_bytes = b"".join([chunk async for chunk in chunks])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_next/isapi.py", line 853, in <listcomp>
    image_bytes = b"".join([chunk async for chunk in chunks])
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/hikvisionapi/hikvisionapi.py", line 289, in opaque_request
    await self._detect_auth_method()
  File "/usr/local/lib/python3.11/site-packages/hikvisionapi/hikvisionapi.py", line 246, in _detect_auth_method
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/httpx/_models.py", line 749, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'http://192.168.1.58/ISAPI/System/status'
For more information check: https://httpstatuses.com/401
2023-08-11 13:58:26.790 DEBUG (MainThread) [custom_components.hikvision_next.notifications] --- Incoming event notification ---

User in use has the requres permissions specified in the Readme.md

maslyankov commented 1 year ago

Full logs: https://pastebin.com/htLqhZsY

Related issue: https://github.com/maciej-or/hikvision_next/issues/69

maslyankov commented 1 year ago

After this happening, I try to setup the DVR using ONVIF with onvif specific user (there are separate users for onvif) I get this error:

Could not authenticate: The device is locked because of entering wrong username/password many times.Please try it after 30 minutes! (code:soap:Sender) (subcodes:{http://www.onvif.org/ver10/error}NotAuthorized)

This makes me believe that the integration is trying to use wrong credentials for some reason, which makes the DVR block the Home Assistant IP.

I reverted to using ONVIF for now.

maciej-or commented 1 year ago

You cannot use ONFIV and hikvision_next integrations together. I get the lowest delays and best performance with hikvision_next and RTSPtoWeb - WebRTC add-on.

maslyankov commented 1 year ago

You cannot use ONFIV and hikvision_next integrations together. I get the lowest delays and best performance with hikvision_next and RTSPtoWeb - WebRTC add-on.

I have not used them together... I had to fallback to ONVIF because hikvision_next does not work... Please read the issue description and comments after it again.

maciej-or commented 1 year ago

ok, sorry I did not read all comments carefully, so I see you have errors by getting camera static image. Please check if you are able to get that from browser http://{user}:{pass}@{ip}/ISAPI/Streaming/channels/101/picture (it should take snapshot from the first camera) and if this option

image

has influence on that

maslyankov commented 1 year ago

ok, sorry I did not read all comments carefully, so I see you have errors by getting camera static image. Please check if you are able to get that from browser http://{user}:{pass}@{ip}/ISAPI/Streaming/channels/101/picture (it should take snapshot from the first camera) and if this option

image

has influence on that

I had previously tried to enable all types of auth that the ui supports. Attaching a screenshot:

Screenshot 2023-08-15 at 1 49 28 AM
maciej-or commented 1 year ago

The option I mentioned is for snapshots only, it overrides general settings in my case. I wonder if you have separate option for that as well? After enabling picture authentication restart NVR might be required to reset failed attempts counter.

maslyankov commented 1 year ago

The option I mentioned is for snapshots only, it overrides general settings in my case. I wonder if you have separate option for that as well? After enabling picture authentication restart NVR might be required to reset failed attempts counter.

There are no other options for security and auth in the DVR config. For snapshots, I have found that the url does not require authentication (weird huh) and I can access it freely: http://192.168.1.58/ISAPI/Streaming/channels/101/picture

1aranzant commented 10 months ago

same issue here, it randomly stops working and gives these kind of logs:

httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'http://192.168.0.213/ISAPI/System/status' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 2023-11-04 00:21:45.483 ERROR (stream_worker) [homeassistant.components.stream.stream.camera.ds_7616ni_e2_16p_a1620161122aarr681759904wcvu_101] Error from stream worker: Error opening stream (INVALIDDATA, Invalid data found when processing input) rtsp://****:****@192.168.0.213:554/Streaming/channels/101