HikSink: An ultra light Hikvision camera event to MQTT bridge

Almost there now. I got HikSink running and reporting line crossing events on one of my cameras. I then tried with another camera (a DS-2CD2086G2-IU with firmware V5.5.131 build 200220 and web V4.0.1 build 191220). I can see Hiksink connect to the first camera OK, but it’s attempts to connect to the second camera fail with the following ERROR message:

Error reconnecting to camera. Could not authenticate with camera: Invalid status code after auth token sent: 500

Any and all help in solving this is much appreciated.

That sounds like a firmware issue with the camera. Code 500 is a server side problem, which I have seen on cameras with outdated firmware before. Is that the newest firmware available?

It was a firmware problem. I upgraded to V5.5.801 build 211105 and HikSink now works perfectly with that camera. Unfortunately I was unable to upgrade to the very latest firmware - for some reason the upgrade failed.
Thanks for your help.

Awesome, thanks for reporting back that it works. I’m concerned by the reliability of the update process, I also nearly bricked my AccuSense camera upgrading to the latest FW.

Cheers ! The other camera I am using with Hiksink does however give me an issue. It keeps cycling between clear and unavailable every second or so. It is a DS-2CD2046G2-IU with firmware version V5.7.10 build 220830.

That’s curious, I have a camera from the same series which seems to work fairly reliably, albeit on an old firmware version. Is it cycling on all the sensors? Also are you seeing any warnings in the logs?

Lots of the following messages in the log:
Camera connection established
Stream could not be resolved to a multipart form: Couldn’t get next part of stream: bad boundary. Attempting reconnection…

There are also quite a large number of the following

MQTT Connection error encountered: I/O: Connection refused (os error 111)

Although HikSink must be able to connect to MQTT as it constantly cycles through CLEAR and UNAVAILABLE

Hello @CornerBit. Can You describe little more how the HikSink can be used with NVR? My cams are connected directly to NVR, and I don’t have access from home network to them.
So do I need to chenge something in conncetion to make them available in home network? Maybe there is an option like in native integration to just set ups IP from NVR?
TIA and have a nice day!
PS. I just foud the option Virtual host on my NVR. Now I’m able to connecto to cams from my home network. I will try to make it work :slight_smile:
PS2. These log I get from docker logs hiksink

ERROR Camera coms{camera=Taras id=taras}: hik_sink::hikapi::camera: Error reconnecting to camera Could not authenticate with camera: Digest not supported by camera.

PS2 One of the cam doesn’t worki with digest autorization :frowning:

curl --basic -u user:password http://192.168.1.11:65004/ISAPI/Smart/LineDetection/1
<?xml version="1.0" encoding="UTF-8"?>
<ResponseStatus version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
<requestURL>/ISAPI/Smart/LineDetection/1</requestURL>
<statusCode>4</statusCode>
<statusString>Invalid Operation</statusString>
<subStatusCode>notSupport</subStatusCode>
</ResponseStatus>

There are a couple of strange errors there. The camera multipart form issue has been raised by another user on github. It looks like the 2022 firmware on Hikvision cameras sends image snapshots via the eventstream directly after the XML which breaks the parser. I’m currently trying to get a hold of a camera with newer firmware so that I can handle this case.
The second MQTT issue looks to be a networking issue. Do you have some kind of firewall between HikSink and the MQTT server? Since it’s intermittent, it seems like its getting kicked off and then is unable to reconnect

It’s likely that digest auth has just been turned off. There’s an option to turn on digest auth when you sign into the camera directly under its configuration page. Try giving that a toggle and let me know if that fixes it

Sorry it has taken so long to reply. I just tries switching RTSP and Web Authentication to ‘Digest/Basic’ and then back to ‘Digest’ and the camera exhibits the same behaviour with both settings.

Hello,

i tried set this up in Docker-compose, it pulls the image etc. put i get errors:

thread ‘main’ panicked at ‘called Result::unwrap() on an Err value: “missing field system”’, src/main.rs:30:58
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread ‘main’ panicked at ‘called Result::unwrap() on an Err value: “missing field system”’, src/main.rs:30:58
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread ‘main’ panicked at ‘called Result::unwrap() on an Err value: “missing field system”’, src/main.rs:30:58
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread ‘main’ panicked at ‘called Result::unwrap() on an Err value: “missing field system”’, src/main.rs:30:58
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread ‘main’ panicked at ‘called Result::unwrap() on an Err value: “missing field system”’, src/main.rs:30:58
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread ‘main’ panicked at ‘called Result::unwrap() on an Err value: “missing field system”’, src/main.rs:30:58
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread ‘main’ panicked at ‘called Result::unwrap() on an Err value: “missing field system”’, src/main.rs:30:58
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread ‘main’ panicked at ‘called Result::unwrap() on an Err value: “missing field system”’, src/main.rs:30:58
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread ‘main’ panicked at ‘called Result::unwrap() on an Err value: “missing field system”’, src/main.rs:30:58
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

its running on a hp server, not a rpi