eu-evops / homebridge-hikvision

28 stars 21 forks source link

Authentication error #18

Open Jaco-VanderMerwe opened 3 years ago

Jaco-VanderMerwe commented 3 years ago

I manage to connect to the NVR, but then get an error when trying to load the cameras. I am able to connect and see the camera feeds using the same credentials with homebridge-camera-ffmpeg. However, with homebridge-camera-ffmpeg I use port 554 (through rtsp), whereas I use port 80 for this plugin because it seems to get me further (when I use port 554, I get an error like in #6 ) Note: I have homebridge-camera-ffmpeg installed & configured, and it works.

My Homebridge config:

        {
            "platform": "Hikvision",
            "name": "Hikvision",
            "host": "192.168.xxx.xxx",
            "port": 80,
            "username": "admin",
            "password": "xxxxxxxxx"
        }

My Homebridge log is as follows:

[2/4/2021, 4:52:29 PM] [Hikvision] Connected to NVR system: {
  DeviceInfo: {
    '$': {
      version: '1.0',
      xmlns: 'http://www.hikvision.com/ver20/XMLSchema'
    },
    deviceName: 'Network Video Recorder',
    deviceID: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
    model: 'DS-7616NI-K2/16P',
    serialNumber: 'DS-7616NI-K2/16Pxxxxxxxxxxxxxxxxxxxxxxxx',
    macAddress: 'xx:xx:xx:xx:xx:xx',
    firmwareVersion: 'V3.4.101',
    firmwareReleasedDate: 'build 180904',
    encoderVersion: 'V5.0',
    encoderReleasedDate: 'build 180903',
    deviceType: 'IPC',
    telecontrolID: '255'
  }
}
[2/4/2021, 4:52:29 PM] [Hikvision] Loading cameras...
(node:26109) UnhandledPromiseRejectionWarning: Error: Request failed with status code 403
    at createError (/homebridge/node_modules/@evops/homebridge-hikvision/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/homebridge/node_modules/@evops/homebridge-hikvision/node_modules/axios/lib/core/settle.js:18:12)
    at IncomingMessage.handleStreamEnd (/homebridge/node_modules/@evops/homebridge-hikvision/node_modules/axios/lib/adapters/http.js:202:11)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
(node:26109) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 15)
(node:26109) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I then used curl as follows, in an attempt to gain more understanding of the problem. Unfortunately I don't know how to interpret this output below:

pi@RaspberryPi:~ $ curl -v http://192.168.xxx.xxx/ISAPI -u admin
Enter host password for user 'admin':
* Expire in 0 ms for 6 (transfer 0x19448a0)
*   Trying 192.168.xxx.xxx...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x19448a0)
* Connected to 192.168.xxx.xxx (192.168.xxx.xxx) port 80 (#0)
* Server auth using Basic with user 'admin'
> GET /ISAPI HTTP/1.1
> Host: 192.168.xxx.xxx
> Authorization: Basic ************* # Masking our credentials
> User-Agent: curl/7.64.0
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Date: Thu, 04 Feb 2021 17:15:34 GMT
< Server: DNVRS-Webs
< Cache-Control: no-cache
< Content-Length: 138
< Content-Type: application/xml; charset="UTF-8"
< Connection: keep-alive
< Keep-Alive: timeout=60, max=99
< WWW-Authenticate: Digest realm="e9d1c27a09ea2483fcaa314f", domain="::", qop="auth", nonce="30db18ed3425524e94dedaf20ed43695:1612458934136", opaque="", algorithm="MD5", stale="FALSE"
<
<?xml version="1.0" encoding="UTF-8" ?>
<userCheck>
<statusValue>401</statusValue>
<statusString>Unauthorized</statusString>
</userCheck>
* Connection #0 to host 192.168.xxx.xxx left intact
sponte commented 3 years ago

From the output above, it seems like basic auth is not enabled - that would explain the curl failure. With regards to actual plugin not working - you're right connecting through port 80 - this is the port of the NVR. Once connected, the plugin queries the system for the number of available cameras, and for each one it finds, it generates very similar configuration to what you'd configured with camera-ffmpeg. 403 means permission denied though - are your cameras connected directly to the NVR using PoE?