Open Deki60 opened 2 years ago
Hey, it looks like something related to security settings on your camera/NVR because images don't require authentication to be taken.
The bot uses digest authentication and this is how my camera is configured:
thank you for reply
i have put the same digest and i have try digest/basic but same error
and camera setting :
Please try to change MD5 Digest Algorithm to something different (and show me all the options), because I don't know which one is being used by my cameras since I don't have the same settings as you.
I have this possibility :
Okay, looks like my cam also uses MD5 and it works. Can you please replace content of this file https://github.com/tropicoo/hikvision-camera-bot/blob/da14bc66fd7a6ba217f21b70d75ef3d6331901ee/hikcamerabot/clients/hikvision/auth.py
with this, rebuild the container and show me the logs (there shouldn't be your password visible, but please double check.
import logging
from typing import Generator
import httpx
log = logging.getLogger()
class DigestAuthCached(httpx.DigestAuth):
"""Hack from https://github.com/encode/httpx/issues/1467."""
__challenge = None
def auth_flow(
self, request: httpx.Request
) -> Generator[httpx.Request, httpx.Response, None]:
if self.__challenge:
request.headers['Authorization'] = self._build_auth_header(
request, self.__challenge
)
log.critical('Challenge: %s', self.__challenge)
log.critical('Request headers: %s', request.headers)
log.critical('Request headers: %s', request.headers)
response = yield request
log.critical('Response headers: %s', response.headers)
if response.status_code != 401 or 'www-authenticate' not in response.headers:
# If the response is not a 401 then we don't
# need to build an authenticated request.
return
for auth_header in response.headers.get_list('www-authenticate'):
if auth_header.lower().startswith('digest '):
break
else:
# If the response does not include a 'WWW-Authenticate: Digest ...'
# header, then we don't need to build an authenticated request.
return
self.__challenge = self._parse_challenge(request, response, auth_header)
request.headers['Authorization'] = self._build_auth_header(
request, self.__challenge
)
log.critical('Request headers after build: %s', request.headers)
log.critical('Request auth details: %s', request.headers['authorization'])
yield request
hikvision_camera_bot | 2022-10-18 10:59:19,213 - [ERROR] - [HikvisionAPIClient:62] - Error during API call: Bad response code 403
hikvision_camera_bot | 2022-10-18 10:59:19,716 - [DEBUG] - [HikvisionAPIClient:40] - Request: GET - ISAPI/Smart/LineDetection/1 - None
hikvision_camera_bot | 2022-10-18 10:59:19,718 - [CRITICAL] - [root:22] - Challenge: _DigestAuthChallenge(realm=b'd602106335cbbf0be80cdbc1', nonce=b'a904b241bbe4b6fe:d602106335cbbf0be80cdbc1:183eabf2cb2:4c3f', algorithm='MD5', opaque=b'799d5', qop=b'auth')
hikvision_camera_bot | 2022-10-18 10:59:19,718 - [CRITICAL] - [root:23] - Request headers: Headers({'host': '192.168.1.250:30443', 'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'python-httpx/0.23.0', 'authorization': '[secure]'})
hikvision_camera_bot | 2022-10-18 10:59:19,718 - [CRITICAL] - [root:24] - Request headers: Headers({'host': '192.168.1.250:30443', 'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'python-httpx/0.23.0', 'authorization': '[secure]'})
hikvision_camera_bot | 2022-10-18 10:59:19,724 - [DEBUG] - [asyncio:808] - <_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>> resumes reading
hikvision_camera_bot | 2022-10-18 10:59:19,727 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=12 read=idle write=<idle, bufsize=0>> pauses reading
hikvision_camera_bot | 2022-10-18 10:59:19,729 - [DEBUG] - [httpx._client:1728] - HTTP Request: GET https://192.168.1.250:30443/ISAPI/Smart/LineDetection/1 "HTTP/1.1 403 Forbidden"
hikvision_camera_bot | 2022-10-18 10:59:19,729 - [CRITICAL] - [root:28] - Response headers: Headers({'vary': 'Accept-Encoding', 'x-frame-options': 'SAMEORIGIN', 'content-type': 'application/xml; charset="UTF-8"', 'x-content-type-options': 'nosniff', 'date': 'Tue, 18 Oct 2022 10:59:16 GMT', 'content-length': '304', 'x-xss-protection': '1; mode=block', 'connection': 'Keep-Alive', 'accept-ranges': 'bytes'})
Can you try to keep the first option digest/basic
on your camera admin panel and change this line in this file
to
auth=httpx.BasicAuth(
and check whether it works for you.
I have modified file,
i have try with setting digest/basic
and same result :
hikvision_camera_bot | 2022-10-19 14:53:47,527 - [DEBUG] - [httpx._client:1728] - HTTP Request: GET https://192.168.1.250:30443/ISAPI/Smart/LineDetection/1 "HTTP/1.1 403 Forbidden"
hikvision_camera_bot | 2022-10-19 14:53:47,528 - [ERROR] - [HikvisionAPIClient:62] - Error during API call: Bad response code 403
hikvision_camera_bot | 2022-10-19 14:53:48,030 - [DEBUG] - [HikvisionAPIClient:40] - Request: GET - ISAPI/Smart/LineDetection/1 - None
hikvision_camera_bot | 2022-10-19 14:53:48,036 - [DEBUG] - [asyncio:808] - <_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>> resumes reading
hikvision_camera_bot | 2022-10-19 14:53:48,039 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=12 read=idle write=<idle, bufsize=0>> pauses reading
i have try with setting digest
and now error is not 403 but 401
hikvision_camera_bot | 2022-10-19 14:54:31,295 - [ERROR] - [HikvisionAPIClient:62] - Error during API call: Bad response code 401
hikvision_camera_bot | 2022-10-19 14:54:31,797 - [DEBUG] - [HikvisionAPIClient:40] - Request: GET - ISAPI/Smart/LineDetection/1 - None
hikvision_camera_bot | 2022-10-19 14:54:31,804 - [DEBUG] - [asyncio:808] - <_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>> resumes reading
hikvision_camera_bot | 2022-10-19 14:54:31,806 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=12 read=idle write=<idle, bufsize=0>> pauses reading
hikvision_camera_bot | 2022-10-19 14:54:31,808 - [DEBUG] - [httpx._client:1728] - HTTP Request: GET https://192.168.1.250:30443/ISAPI/Smart/LineDetection/1 "HTTP/1.1 401 Unauthorized
question could there be a certificate problem? when I enter on a web page, i have the certificate message "the connection is not private"
(yet the HTTP protocol is activated)
Update : same when i try direcly on cam , i successfuly get cam picture but other nothing
Config :
"cam_2": {
"hidden": false,
"description": "hall",
"hashtag": "hall",
"group": "Default group",
"api": {
"host": "http://192.168.1.250:65002",
"auth": {
"user": "*********",
"password": "*******"
},
"stream_timeout": 10
},
"rtsp_port": 554,
"video_gif": {
"on_demand": {
"channel": 102,
"record_time": 10,
"rewind_time": 10,
"tmp_storage": "/tmp",
"loglevel": "error",
"rtsp_transport_type": "tcp"
log :
hikvision_camera_bot | 2022-10-19 16:26:53,237 - [ERROR] - [HikvisionAPIClient:62] - Error during API call: Bad response code 403
hikvision_camera_bot | 2022-10-19 16:26:53,740 - [DEBUG] - [HikvisionAPIClient:40] - Request: GET - ISAPI/Smart/LineDetection/1 - None
hikvision_camera_bot | 2022-10-19 16:26:53,746 - [DEBUG] - [asyncio:808] - <_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>> resumes reading
hikvision_camera_bot | 2022-10-19 16:26:53,749 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=12 read=idle write=<idle, bufsize=0>> pauses reading
hikvision_camera_bot | 2022-10-19 16:26:53,751 - [DEBUG] - [httpx._client:1728] - HTTP Request: GET http://192.168.1.250:65002/ISAPI/Smart/LineDetection/1 "HTTP/1.1 403 Forbidden"
Maybe some NVR security settings forbid us to do API calls since we can see that when the auth fails we have 401 Unauthorized code and 403 Forbidden (when authorization probably succeeds). Maybe user don't have full access? Maybe there is some checkbox on camera or NVR or both that will allow doing API calls?
What we can also try is to add a log for the response data: https://github.com/tropicoo/hikvision-camera-bot/blob/6242f3ac974ea40e1709ba9f93eeb4e17fd12ad9/hikcamerabot/clients/hikvision/api_client.py#L57
After that line add
self._log.debug('Response data: %s - %s', response.headers, response.data)
User is admin and have full acces
i have add your line :
hikvision_camera_bot | 2022-10-19 17:41:14,150 - [INFO] - [TaskDetectionConf:77] - Enabling camera's Line Crossing Detection has been requested
hikvision_camera_bot | 2022-10-19 17:41:14,150 - [DEBUG] - [AlarmService:101] - Enabling Line Crossing Detection
hikvision_camera_bot | 2022-10-19 17:41:14,151 - [DEBUG] - [HikvisionAPIClient:40] - Request: GET - ISAPI/Smart/LineDetection/1 - None
hikvision_camera_bot | 2022-10-19 17:41:14,157 - [DEBUG] - [asyncio:1096] - <asyncio.TransportSocket fd=12, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('172.18.0.3', 59988), raddr=('192.168.1.250', 65002)> connected to 192.168.1.250:65002: (<_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>>, <anyio._backends._asyncio.StreamProtocol object at 0x7f40963afa30>)
hikvision_camera_bot | 2022-10-19 17:41:14,158 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=12 read=idle write=<idle, bufsize=0>> pauses reading
hikvision_camera_bot | 2022-10-19 17:41:14,161 - [DEBUG] - [asyncio:808] - <_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>> resumes reading
hikvision_camera_bot | 2022-10-19 17:41:14,168 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=12 read=idle write=<idle, bufsize=0>> pauses reading
hikvision_camera_bot | 2022-10-19 17:41:14,169 - [DEBUG] - [httpx._client:1728] - HTTP Request: GET http://192.168.4.250:65002/ISAPI/Smart/LineDetection/1 "HTTP/1.1 403 Forbidden"
hikvision_camera_bot | 2022-10-19 17:41:14,170 - [ERROR] - [HikvisionAPIClient:63] - Error during API call: Bad response code 403
on NVR API is enable (i have add user admin but same result) :
on service network i have https / TLS / SDK / RTPS / Websocket and IOT :
on camera i have actived Hikvision-CGI for try (same result)
and on camera i have try disable HTTPS for only http wihtout certificat but same result :
I don't see a log message in your reply Response data: ...
, maybe you forgot to rebuild/restart the container?
Is there any way to access your camera directly without going through NVR? Also, is there a possibility to check again but with disabled HTTPS/TLS?
i have disable HTTPS/TLS but same result ever 403 Forbiden.
I have rebuild, maybe error in line ?
"""Hikvision camera API client module."""
import logging
from typing import Any
from urllib.parse import urljoin
import httpx
from addict import Dict
from tenacity import retry, wait_fixed
from hikcamerabot.clients.hikvision.auth import DigestAuthCached
from hikcamerabot.constants import CONN_TIMEOUT
from hikcamerabot.exceptions import APIBadResponseCodeError, APIRequestError
class HikvisionAPIClient:
"""Hikvision API Class."""
def __init__(self, conf: Dict) -> None:
self._log = logging.getLogger(self.__class__.__name__)
self._conf = conf
self.host: str = self._conf.host
self.session = httpx.AsyncClient(
auth=httpx.BasicAuth(
username=self._conf.auth.user,
password=self._conf.auth.password,
),
transport=httpx.AsyncHTTPTransport(verify=False, retries=3),
)
@retry(wait=wait_fixed(0.5))
async def request(
self,
endpoint: str,
data: Any = None,
headers: dict = None,
method: str = 'GET',
timeout: float = CONN_TIMEOUT,
) -> httpx.Response:
url = urljoin(self.host, endpoint)
self._log.debug('Request: %s - %s - %s', method, endpoint, data)
try:
response = await self.session.request(
method,
url=url,
data=data,
headers=headers,
timeout=timeout,
)
except Exception as err:
err_msg = (
f'API encountered an unknown error for method {method}, '
f'endpoint {endpoint}, data {data}'
)
self._log.debug('Response data: %s - %s', response.headers, response.data)
self._log.exception(err_msg)
raise APIRequestError(f'{err_msg}: {err}') from err
self._verify_status_code(response.status_code)
return response
def _verify_status_code(self, status_code: int) -> None:
if httpx.codes.is_error(status_code):
err_msg = f'Error during API call: Bad response code {status_code}'
self._log.error(err_msg)
raise APIBadResponseCodeError(err_msg)
Yeah, put it here, before except Exception as err:
Ah, please change response.data
to response.text
because you will have an error
When i add this code after line 57 i have that :
hikvision_camera_bot exited with code 1
hikvision_camera_bot | Traceback (most recent call last):
hikvision_camera_bot | File "/app/./bot.py", line 6, in <module>
hikvision_camera_bot | from hikcamerabot.launcher import BotLauncher
hikvision_camera_bot | File "/app/hikcamerabot/launcher.py", line 4, in <module>
hikvision_camera_bot | from hikcamerabot.bot_setup import BotSetup
hikvision_camera_bot | File "/app/hikcamerabot/bot_setup.py", line 8, in <module>
hikvision_camera_bot | from hikcamerabot.callbacks import cmd_list_group_cams
hikvision_camera_bot | File "/app/hikcamerabot/callbacks.py", line 6, in <module>
hikvision_camera_bot | from hikcamerabot.camera import HikvisionCam
hikvision_camera_bot | File "/app/hikcamerabot/camera.py", line 12, in <module>
hikvision_camera_bot | from hikcamerabot.clients.hikvision import HikvisionAPI, HikvisionAPIClient
hikvision_camera_bot | File "/app/hikcamerabot/clients/hikvision/__init__.py", line 1, in <module>
hikvision_camera_bot | from hikcamerabot.clients.hikvision.api_client import HikvisionAPIClient
hikvision_camera_bot | File "/app/hikcamerabot/clients/hikvision/api_client.py", line 49
hikvision_camera_bot | self._log.debug('Response data: %s - %s', response.headers, response.text)
hikvision_camera_bot | TabError: inconsistent use of tabs and spaces in indentation
or that if i don't line up
hikvision_camera_bot exited with code 1
hikvision_camera_bot | Traceback (most recent call last):
hikvision_camera_bot | File "/app/./bot.py", line 6, in <module>
hikvision_camera_bot | from hikcamerabot.launcher import BotLauncher
hikvision_camera_bot | File "/app/hikcamerabot/launcher.py", line 4, in <module>
hikvision_camera_bot | from hikcamerabot.bot_setup import BotSetup
hikvision_camera_bot | File "/app/hikcamerabot/bot_setup.py", line 8, in <module>
hikvision_camera_bot | from hikcamerabot.callbacks import cmd_list_group_cams
hikvision_camera_bot | File "/app/hikcamerabot/callbacks.py", line 6, in <module>
hikvision_camera_bot | from hikcamerabot.camera import HikvisionCam
hikvision_camera_bot | File "/app/hikcamerabot/camera.py", line 12, in <module>
hikvision_camera_bot | from hikcamerabot.clients.hikvision import HikvisionAPI, HikvisionAPIClient
hikvision_camera_bot | File "/app/hikcamerabot/clients/hikvision/__init__.py", line 1, in <module>
hikvision_camera_bot | from hikcamerabot.clients.hikvision.api_client import HikvisionAPIClient
hikvision_camera_bot | File "/app/hikcamerabot/clients/hikvision/api_client.py", line 49
hikvision_camera_bot | self._log.debug('Response data: %s - %s', response.headers, response.text)
hikvision_camera_bot | SyntaxError: expected 'except' or 'finally' block
It should be like this. You have the wrong indentation with spaces. You've probably hit a TAB but there should be only spaces
Yes, i have tab problem, sorry for that
Line Detection :
hikvision_camera_bot | 2022-10-20 09:10:19,763 - [ERROR] - [HikvisionAPIClient:63] - Error during API call: Bad response code 403
hikvision_camera_bot | 2022-10-20 09:10:20,265 - [DEBUG] - [HikvisionAPIClient:40] - Request: GET - ISAPI/Smart/LineDetection/1 - None
hikvision_camera_bot | 2022-10-20 09:10:20,271 - [DEBUG] - [asyncio:808] - <_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>> resumes reading
hikvision_camera_bot | 2022-10-20 09:10:20,273 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=12 read=idle write=<idle, bufsize=0>> pauses reading
hikvision_camera_bot | 2022-10-20 09:10:20,275 - [DEBUG] - [httpx._client:1728] - HTTP Request: GET http://192.168.1.250/ISAPI/Smart/LineDetection/1 "HTTP/1.1 403 Forbidden"
hikvision_camera_bot | 2022-10-20 09:10:20,277 - [DEBUG] - [HikvisionAPIClient:49] - Response data: Headers({'vary': 'Accept-Encoding', 'x-frame-options': 'SAMEORIGIN', 'content-type': 'application/xml; charset="UTF-8"', 'x-content-type-options': 'nosniff', 'date': 'Thu, 20 Oct 2022 09:10:09 GMT', 'content-length': '304', 'x-xss-protection': '1; mode=block', 'connection': 'Keep-Alive', 'accept-ranges': 'bytes'}) - <?xml version="1.0" encoding="UTF-8" ?>
hikvision_camera_bot | <ResponseStatus version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
hikvision_camera_bot | <requestURL>/ISAPI/Smart/LineDetection/1</requestURL>
hikvision_camera_bot | <statusCode>4</statusCode>
hikvision_camera_bot | <statusString>Invalid Operation</statusString>
hikvision_camera_bot | <subStatusCode>notSupport</subStatusCode>
hikvision_camera_bot | </ResponseStatus>
hikvision_camera_bot |
Motion Detection :
hikvision_camera_bot | 2022-10-20 09:50:28,969 - [ERROR] - [HikvisionAPIClient:55] - API encountered an unknown error for method GET, endpoint ISAPI/System/Video/inputs/channels/1/motionDetection, data None
hikvision_camera_bot | Traceback (most recent call last):
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpcore/backends/asyncio.py", line 33, in read
hikvision_camera_bot | return await self._stream.receive(max_bytes=max_bytes)
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 1265, in receive
hikvision_camera_bot | await self._protocol.read_event.wait()
hikvision_camera_bot | File "/usr/local/lib/python3.10/asyncio/locks.py", line 214, in wait
hikvision_camera_bot | await fut
hikvision_camera_bot | asyncio.exceptions.CancelledError
hikvision_camera_bot |
hikvision_camera_bot | During handling of the above exception, another exception occurred:
hikvision_camera_bot |
hikvision_camera_bot | Traceback (most recent call last):
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpcore/_exceptions.py", line 8, in map_exceptions
hikvision_camera_bot | yield
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpcore/backends/asyncio.py", line 31, in read
hikvision_camera_bot | with anyio.fail_after(timeout):
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/anyio/_core/_tasks.py", line 118, in __exit__
hikvision_camera_bot | raise TimeoutError
hikvision_camera_bot | TimeoutError
hikvision_camera_bot |
hikvision_camera_bot | During handling of the above exception, another exception occurred:
hikvision_camera_bot |
hikvision_camera_bot | Traceback (most recent call last):
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
hikvision_camera_bot | yield
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 239, in __aiter__
hikvision_camera_bot | async for part in self._httpcore_stream:
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 346, in __aiter__
hikvision_camera_bot | async for part in self._stream:
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 300, in __aiter__
hikvision_camera_bot | raise exc
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 293, in __aiter__
hikvision_camera_bot | async for chunk in self._connection._receive_response_body(**kwargs):
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 165, in _receive_response_body
hikvision_camera_bot | event = await self._receive_event(timeout=timeout)
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 177, in _receive_event
hikvision_camera_bot | data = await self._network_stream.read(
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpcore/backends/asyncio.py", line 30, in read
hikvision_camera_bot | with map_exceptions(exc_map):
hikvision_camera_bot | File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__
hikvision_camera_bot | self.gen.throw(typ, value, traceback)
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
hikvision_camera_bot | raise to_exc(exc)
hikvision_camera_bot | httpcore.ReadTimeout
hikvision_camera_bot |
hikvision_camera_bot | The above exception was the direct cause of the following exception:
hikvision_camera_bot |
hikvision_camera_bot | Traceback (most recent call last):
hikvision_camera_bot | File "/app/hikcamerabot/clients/hikvision/api_client.py", line 42, in request
hikvision_camera_bot | response = await self.session.request(
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1527, in request
hikvision_camera_bot | return await self.send(request, auth=auth, follow_redirects=follow_redirects)
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1628, in send
hikvision_camera_bot | raise exc
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1622, in send
hikvision_camera_bot | await response.aread()
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpx/_models.py", line 896, in aread
hikvision_camera_bot | self._content = b"".join([part async for part in self.aiter_bytes()])
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpx/_models.py", line 896, in <listcomp>
hikvision_camera_bot | self._content = b"".join([part async for part in self.aiter_bytes()])
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpx/_models.py", line 914, in aiter_bytes
hikvision_camera_bot | async for raw_bytes in self.aiter_raw():
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpx/_models.py", line 972, in aiter_raw
hikvision_camera_bot | async for raw_stream_bytes in self.stream:
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 146, in __aiter__
hikvision_camera_bot | async for chunk in self._stream:
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 238, in __aiter__
hikvision_camera_bot | with map_httpcore_exceptions():
hikvision_camera_bot | File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__
hikvision_camera_bot | self.gen.throw(typ, value, traceback)
hikvision_camera_bot | File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
hikvision_camera_bot | raise mapped_exc(message) from exc
hikvision_camera_bot | httpx.ReadTimeout
hikvision_camera_bot | 2022-10-20 09:50:29,476 - [DEBUG] - [HikvisionAPIClient:40] - Request: GET - ISAPI/System/Video/inputs/channels/1/motionDetection - None
hikvision_camera_bot | 2022-10-20 09:50:29,486 - [DEBUG] - [asyncio:1096] - <asyncio.TransportSocket fd=12, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('172.18.0.3', 59922), raddr=('192.168.1.250', 80)> connected to 192.168.1.250:80: (<_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>>, <anyio._backends._asyncio.StreamProtocol object at 0x7f1d130b2c20>)
hikvision_camera_bot | 2022-10-20 09:50:29,487 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=12 read=idle write=<idle, bufsize=0>> pauses reading
hikvision_camera_bot | 2022-10-20 09:50:29,493 - [DEBUG] - [asyncio:808] - <_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>> resumes reading
hikvision_camera_bot | 2022-10-20 09:50:29,498 - [DEBUG] - [asyncio:800] - <_SelectorSocketTransport fd=12 read=idle write=<idle, bufsize=0>> pauses reading
hikvision_camera_bot | 2022-10-20 09:50:29,500 - [DEBUG] - [httpx._client:1728] - HTTP Request: GET http://192.168.1.250/ISAPI/System/Video/inputs/channels/1/motionDetection "HTTP/1.1 200 OK"
hikvision_camera_bot | 2022-10-20 09:50:29,502 - [DEBUG] - [asyncio:808] - <_SelectorSocketTransport fd=12 read=polling write=<idle, bufsize=0>> resumes reading
if i put direct link in web i have that :
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<MotionDetection xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<enabled>true</enabled>
<enableHighlight>true</enableHighlight>
<samplingInterval>2</samplingInterval>
<startTriggerTime>500</startTriggerTime>
<endTriggerTime>500</endTriggerTime>
<regionType>grid</regionType>
<Grid>
<rowGranularity>18</rowGranularity>
<columnGranularity>22</columnGranularity>
</Grid>
<MotionDetectionLayout xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<sensitivityLevel>80</sensitivityLevel>
<layout>
<gridMap>000000000000001fe0001fe0001fe0001fe0001fe0001fe0001fe0001fe0001fe0001fe0001fe0001fe0001fe0001fe0000000000000</gridMap>
<RegionList size="4">
<Region>
<id>1</id>
<RegionCoordinatesList>
<RegionCoordinates>
<positionX>501</positionX>
<positionY>888</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>863</positionX>
<positionY>888</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>863</positionX>
<positionY>112</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>501</positionX>
<positionY>112</positionY>
</RegionCoordinates>
</RegionCoordinatesList>
</Region>
</RegionList>
</layout>
</MotionDetectionLayout>
</MotionDetection>
Which exact direct link did you use? In your logs I see you had a host with and without port (default 80):
HTTP Request: GET https://192.168.1.250:30443/ISAPI/Smart/LineDetection/1 "HTTP/1.1 403 Forbidden"
...
HTTP Request: GET http://192.168.1.250:65002/ISAPI/Smart/LineDetection/1 "HTTP/1.1 403 Forbidden"
...
HTTP Request: GET http://192.168.1.250/ISAPI/System/Video/inputs/channels/1/motionDetection "HTTP/1.1 200 OK"
Sorry for delay answer, port 30443 it's https, 65002 it's internal cam 2 port and 80 http port i cam talk with camera directly with internal port, https and http talk with NVR
Dear, Thank you very much for your work !
i have install and try to use it, it work fine to receive images on request. However, when I try to control the activation of the cameras via the telegram bot (line detection, motion detection...) I constantly receive Forbiden 403 errors. Yet I have well informed the login / pass in the config. Note that the cameras are behind an NVR. Is there a specific thing to do to fix this problem?