Supergiovane / node-red-contrib-hikvision-ultimate

A native set of node for Hikvision Cameras, Doorbells, Alarms, Radars etc.
https://www.facebook.com/supergiovaneDev
MIT License
46 stars 12 forks source link

Node-red stops after UnhandledPromiseRejectionWarning #27

Closed djivkov closed 1 year ago

djivkov commented 2 years ago

Node-RED version: 2.1.3 Node.js version: 12.22.7 npm version: 6.14.15 Platform/OS: Raspbian Camera: DS-2CD2343G2-I, firmware: V5.7.1 build 211009

Oct 31 23:04:23 raspberrypi Node-RED[12424]: (node:12424) UnhandledPromiseRejectionWarning: Error: Text data outside of root node. Oct 31 23:04:23 raspberrypi Node-RED[12424]: Line: 6 Oct 31 23:04:23 raspberrypi Node-RED[12424]: Column: 12 Oct 31 23:04:23 raspberrypi Node-RED[12424]: Char: 1 Oct 31 23:04:23 raspberrypi Node-RED[12424]: at error (/root/.node-red/node_modules/sax/lib/sax.js:651:10) Oct 31 23:04:23 raspberrypi Node-RED[12424]: at strictFail (/root/.node-red/node_modules/sax/lib/sax.js:677:7) Oct 31 23:04:23 raspberrypi Node-RED[12424]: at SAXParser.write (/root/.node-red/node_modules/sax/lib/sax.js:1035:15) Oct 31 23:04:23 raspberrypi Node-RED[12424]: at Parser.exports.Parser.Parser.parseString (/root/.node-red/node_modules/xml2js/lib/parser.js:323:31) Oct 31 23:04:23 raspberrypi Node-RED[12424]: at /root/.node-red/node_modules/xml2js/lib/parser.js:5:59 Oct 31 23:04:23 raspberrypi Node-RED[12424]: at /root/.node-red/node_modules/node-red-contrib-hikvision-ultimate/nodes/Hikvision-config.js:179:41 Oct 31 23:04:23 raspberrypi Node-RED[12424]: at Array.forEach () Oct 31 23:04:23 raspberrypi Node-RED[12424]: at handleChunk (/root/.node-red/node_modules/node-red-contrib-hikvision-ultimate/nodes/Hikvision-config.js:170:34) Oct 31 23:04:23 raspberrypi Node-RED[12424]: at Readable. (/root/.node-red/node_modules/node-red-contrib-hikvision-ultimate/nodes/Hikvision-config.js:263:33) Oct 31 23:04:23 raspberrypi Node-RED[12424]: at Readable.emit (events.js:314:20) Oct 31 23:04:23 raspberrypi Node-RED[12424]: (node:12424) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promi$ Oct 31 23:04:23 raspberrypi Node-RED[12424]: (node:12424) [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-ze$

Supergiovane commented 2 years ago

Hi I’ll take a look

Supergiovane commented 2 years ago

Hi, this is an error in a library used by hikvision-ultimate, whenever the XML returned by the camera/NVR is invalid. I worked on a workaround/fix and i'll tell the dev of that library to take a look. V. 1.0.55 is out in about 1 hour. Please test it and let me know if it worked.

djivkov commented 2 years ago

Sure I'll. Thanks Supergiovane !

djivkov commented 2 years ago

In changelog there is a little mistake - knx-ultimate -> hikvision-ultimate

Supergiovane commented 2 years ago

...mmmm... thanks. I'll change it. I'm working on too many nodes at once!

djivkov commented 2 years ago

It's working stable.

Sergio-tix commented 2 years ago

I have the same problem. What did you do to fix everything?

Node-RED version: 1.3.7 Node.js version: 12.22.6 npm_ version: 8.3.0 (The problem was also on ver. 6.12) node-red-contrib-hikvision-ultimate v.1.0.57 Platform/OS: Synology - Docker (As part of the application iobroker, https://registry.hub.docker.com/r/buanet/iobroker/)

Camera: DS-2CD2086G2-UI, firmware: V5.7.1 build 211009 Camera: DS-2CD2386G2-ISU/SL, firmware: V5.5.801 build 210727

2021-12-14 13:58:43.664 - error: node-red.0 (14782) 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().

2021-12-14 13:58:43.667 - error: node-red.0 (14782) unhandled promise rejection: Unmatched closing tag: EventNotificationAlert
Line: 2
Column: 25
Char: >
2021-12-14 13:58:43.668 - error: node-red.0 (14782) Error: Unmatched closing tag: EventNotificationAlert
Line: 2
Column: 25
Char: >
at error (/opt/iobroker/iobroker-data/node-red/node_modules/sax/lib/sax.js:651:10)
at strictFail (/opt/iobroker/iobroker-data/node-red/node_modules/sax/lib/sax.js:677:7)
at closeTag (/opt/iobroker/iobroker-data/node-red/node_modules/sax/lib/sax.js:879:7)
at SAXParser.write (/opt/iobroker/iobroker-data/node-red/node_modules/sax/lib/sax.js:1436:13)
at Parser.exports.Parser.Parser.parseString (/opt/iobroker/iobroker-data/node-red/node_modules/xml2js/lib/parser.js:323:31)
at /opt/iobroker/iobroker-data/node-red/node_modules/xml2js/lib/parser.js:5:59
at /opt/iobroker/iobroker-data/node-red/node_modules/node-red-contrib-hikvision-ultimate/nodes/Hikvision-config.js:177:41
at Array.forEach ()
at handleChunk (/opt/iobroker/iobroker-data/node-red/node_modules/node-red-contrib-hikvision-ultimate/nodes/Hikvision-config.js:168:34)
at Readable. (/opt/iobroker/iobroker-data/node-red/node_modules/node-red-contrib-hikvision-ultimate/nodes/Hikvision-config.js:261:33)
2021-12-14 13:58:43.669 - error: node-red.0 (14782) Unmatched closing tag: EventNotificationAlert
Line: 2
Column: 25
Char: >
2021-12-14 13:58:44.873 - info: node-red.0 (14782) terminating
2021-12-14 13:58:44.874 - warn: node-red.0 (14782) Terminated (UNCAUGHT_EXCEPTION): Without reason
2021-12-14 13:58:47.565 - info: node-red.0 (14782) terminating with timeout
2021-12-14 13:58:50.439 - info: node-red.0 (1322) node-red exited with 6
2021-12-14 13:58:55.441 - info: node-red.0 (1322) Starting node-red: --max-old-space-size=512 /opt/iobroker/node_modules/node-red/red.js -v --settings /opt/iobroker/iobroker-data/node-red/settings.js
2021-12-14 13:58:58.166 - warn: node-red.0 (1322) 14 Dec 13:58:58 - [warn] Projekte deaktiviert: editorTheme.projects.enabled=false
0

NREEEE8D

[{"id":"ca5e1e19.ae749","type":"hikvisionUltimateAlarmRaw","z":"54b087c0.79e268","d":true,"name":"","topic":"","server":"","x":130,"y":100,"wires":[["58908bc.05c9674"],[]]},{"id":"58908bc.05c9674","type":"switch","z":"54b087c0.79e268","name":".eventDescription","property":"payload.eventDescription","propertyType":"msg","rules":[{"t":"eq","v":"fielddetection alarm","vt":"str"},{"t":"eq","v":"linedetection alarm","vt":"str"},{"t":"eq","v":"regionEntrance alarm","vt":"str"},{"t":"eq","v":"regionExiting alarm","vt":"str"}],"checkall":"true","repair":true,"outputs":4,"x":310,"y":100,"wires":[["c7c94210.749d7"],["5444b72c.b4f468"],["58badce7.cfe054"],["3c6fbb83.1e5694"]]},{"id":"c7c94210.749d7","type":"link out","z":"54b087c0.79e268","name":"fielddetection","links":["f5ba2bab.e75fb8"],"x":510,"y":40,"wires":[],"l":true},{"id":"5444b72c.b4f468","type":"link out","z":"54b087c0.79e268","name":"linedetection","links":[],"x":510,"y":80,"wires":[],"l":true},{"id":"58badce7.cfe054","type":"link out","z":"54b087c0.79e268","name":"regionEntrance","links":[],"x":520,"y":120,"wires":[],"l":true},{"id":"3c6fbb83.1e5694","type":"link out","z":"54b087c0.79e268","name":"regionExiting","links":[],"x":510,"y":160,"wires":[],"l":true},{"id":"1c3b0cf2.c078d3","type":"comment","z":"54b087c0.79e268","name":"Smart Event ->","info":"","x":180,"y":260,"wires":[]},{"id":"f5ba2bab.e75fb8","type":"link in","z":"54b087c0.79e268","name":"fielddetection_INPUT","links":["c7c94210.749d7"],"x":115,"y":620,"wires":[["fa0d6a27.1e6598"]]},{"id":"fa0d6a27.1e6598","type":"switch","z":"54b087c0.79e268","name":".regionID","property":"payload.DetectionRegionList.DetectionRegionEntry.regionID","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"}],"checkall":"true","repair":true,"outputs":4,"x":220,"y":620,"wires":[["2b321074.c43cb"],["903cddc6.f135c"],["c8a513.9df8baf"],["ea7f96ff.4f38f8"]]},{"id":"903cddc6.f135c","type":"switch","z":"54b087c0.79e268","name":"Region 2 .detectionTarget","property":"payload.DetectionRegionList.DetectionRegionEntry.detectionTarget","propertyType":"msg","rules":[{"t":"eq","v":"human","vt":"str"},{"t":"eq","v":"vehicle","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":520,"wires":[["a092a6b9.b525f8","6a46b248.1eec1c"],["418212e3.1761ac","cb8efff9.b7752"]]},{"id":"a092a6b9.b525f8","type":"change","z":"54b087c0.79e268","name":"Region 2   human  ","rules":[{"t":"set","p":"payload","pt":"msg","to":"Region 2 human","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":500,"wires":[["148bdbec.21b274"]]},{"id":"418212e3.1761ac","type":"change","z":"54b087c0.79e268","name":"Region 2 vehicle","rules":[{"t":"set","p":"payload","pt":"msg","to":"Region 2 vehicle","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":540,"wires":[["148bdbec.21b274"]]},{"id":"148bdbec.21b274","type":"debug","z":"54b087c0.79e268","name":"Region 2","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":920,"y":520,"wires":[]},{"id":"6a46b248.1eec1c","type":"link out","z":"54b087c0.79e268","name":"Cam_03_Region_2__human","links":[],"x":740,"y":460,"wires":[],"l":true},{"id":"cb8efff9.b7752","type":"link out","z":"54b087c0.79e268","name":"Cam_03_Region_2__vehicle","links":[],"x":740,"y":580,"wires":[],"l":true},{"id":"c8a513.9df8baf","type":"switch","z":"54b087c0.79e268","name":"Region 3 .detectionTarget","property":"payload.DetectionRegionList.DetectionRegionEntry.detectionTarget","propertyType":"msg","rules":[{"t":"eq","v":"human","vt":"str"},{"t":"eq","v":"vehicle","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":700,"wires":[["e39a4442.0bea78","1849e3ef.16a9dc"],["f4354a2e.db8088","9427c95e.64f248"]]},{"id":"e39a4442.0bea78","type":"change","z":"54b087c0.79e268","name":"Region 3   human  ","rules":[{"t":"set","p":"payload","pt":"msg","to":"Region 3 human","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":680,"wires":[["84a11526.978028"]]},{"id":"f4354a2e.db8088","type":"change","z":"54b087c0.79e268","name":"Region 3 vehicle","rules":[{"t":"set","p":"payload","pt":"msg","to":"Region 3 vehicle","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":720,"wires":[["84a11526.978028"]]},{"id":"84a11526.978028","type":"debug","z":"54b087c0.79e268","name":"Region 3","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":920,"y":700,"wires":[]},{"id":"1849e3ef.16a9dc","type":"link out","z":"54b087c0.79e268","name":"Cam_03_Region_3__human","links":[],"x":740,"y":640,"wires":[],"l":true},{"id":"9427c95e.64f248","type":"link out","z":"54b087c0.79e268","name":"Cam_03_Region_3__vehicle","links":[],"x":740,"y":760,"wires":[],"l":true},{"id":"ea7f96ff.4f38f8","type":"switch","z":"54b087c0.79e268","name":"Region 4 .detectionTarget","property":"payload.DetectionRegionList.DetectionRegionEntry.detectionTarget","propertyType":"msg","rules":[{"t":"eq","v":"human","vt":"str"},{"t":"eq","v":"vehicle","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":880,"wires":[["215fe62a.6ce15a","104721f8.e7d0be"],["cf998596.639f08","25dffdc0.a88f52"]]},{"id":"104721f8.e7d0be","type":"link out","z":"54b087c0.79e268","name":"Cam_03_Region_4__human","links":[],"x":740,"y":820,"wires":[],"l":true},{"id":"25dffdc0.a88f52","type":"link out","z":"54b087c0.79e268","name":"Cam_03_Region_4__vehicle","links":[],"x":740,"y":940,"wires":[],"l":true},{"id":"215fe62a.6ce15a","type":"change","z":"54b087c0.79e268","name":"Region 4   human  ","rules":[{"t":"set","p":"payload","pt":"msg","to":"Region 4 human","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":860,"wires":[["5c622365.ec0cec"]]},{"id":"cf998596.639f08","type":"change","z":"54b087c0.79e268","name":"Region 4 vehicle","rules":[{"t":"set","p":"payload","pt":"msg","to":"Region 4 vehicle","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":900,"wires":[["5c622365.ec0cec"]]},{"id":"5c622365.ec0cec","type":"debug","z":"54b087c0.79e268","name":"Region 4","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":920,"y":880,"wires":[]},{"id":"2b321074.c43cb","type":"switch","z":"54b087c0.79e268","name":"Region 1 .detectionTarget","property":"payload.DetectionRegionList.DetectionRegionEntry.detectionTarget","propertyType":"msg","rules":[{"t":"eq","v":"human","vt":"str"},{"t":"eq","v":"vehicle","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":340,"wires":[["631d2b40.d7c714","bd59ae36.09232"],["51c77034.7f16a","66da825c.969a2c"]]},{"id":"631d2b40.d7c714","type":"change","z":"54b087c0.79e268","name":"Region 1 human","rules":[{"t":"set","p":"payload","pt":"msg","to":"Region 1 human","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":320,"wires":[["f67db389.59655"]]},{"id":"51c77034.7f16a","type":"change","z":"54b087c0.79e268","name":"Region 1 vehicle","rules":[{"t":"set","p":"payload","pt":"msg","to":"Region 1 vehicle","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":360,"wires":[["f67db389.59655"]]},{"id":"f67db389.59655","type":"debug","z":"54b087c0.79e268","name":"Region 1","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":920,"y":340,"wires":[]},{"id":"bd59ae36.09232","type":"link out","z":"54b087c0.79e268","name":"Cam_03_Region_1__human","links":[],"x":740,"y":280,"wires":[],"l":true},{"id":"66da825c.969a2c","type":"link out","z":"54b087c0.79e268","name":"Cam_03_Region_1__vehicle","links":[],"x":740,"y":400,"wires":[],"l":true}]

upd/ тткк

Supergiovane commented 2 years ago

Hi node-red-contrib-hikvision-ultimate@1.0.58 is out. You should see the new version in some minutes. Please install it and try. Cheers!

Sergio-tix commented 2 years ago

Thanks for the very quick response! I installed the new version and am starting testing.

Sergio-tix commented 2 years ago

The fall of the node continues. Now it is difficult to understand the reason who is to blame for this, perhaps it is not connected with camera, at the moment there are few statistics. In the log only this:

(node:170) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 101 error listeners added to [Parser]. Use emitter.setMaxListeners() to increase limit

Supergiovane commented 2 years ago

Hi That error tells unfortunately nothing. EventEmitter is a class embedded into node.js, used by near all nodes to emit the events to the subscribers. What you can try to do, is to update node.js to v14, but v12 is already good. I don't know. I'm testing the matter now... please leave me some time... i'm trying to reproduce your issue...

Supergiovane commented 2 years ago

PS: the Unmatched closing tag: EventNotificationAlert is coming from xml2parser and means that your camera sends a notification alert without the last ">" tag in the XML. So i wrapped the XML decoder into a try-catch to get rid of these wrong XML messages. I'll try to simulate a wrong XML and see what happen...

Supergiovane commented 2 years ago

PPS: can you please add a banana to your configuration and restart node-red? This enables the full log. As soon as you encounter the error, please paste here again the log. Thanks.

Node-RED
Sergio-tix commented 2 years ago

iobroker.2021-12-15.log.zip It turned out to be a large LOG. There were no falls, but there was a trigger SMART.

Supergiovane commented 2 years ago

Thanks sorry.... do you have enablet "motion alert" in the camera? Or maybe other smart events like "intrusion detection" etc?

Supergiovane commented 2 years ago

...and maybe this is the issue: "5720229152Cam_03binary1" MAYBE your cam is trying to send something in binary mode (maybe a picture?) with the alarm stream. Can it be? How do you have set your camera to send the picture?

Sergio-tix commented 2 years ago

In my camera, ALL events are configured and used. These are 4 zones, 4 line crossings, 4 invasions into the region and 4 exits from the region. It's a lot? Can't use everything? Thanks for your work. My problem appears in all situations when the camera detects something from the SMART actions. But most often, almost always, the problem manifests itself in multiple events. For example, when three to five people in a crowd cross the line - 100% will be a crash. I am not using the camera to send an image. I pull the image from the camera using ffmpeg, capturing the stream from the camera, and then saving the .jpg or .gif to disk. I will check the camera settings, I didn’t know the camera can send images.

Supergiovane commented 2 years ago

Hi thanks for the clarification. Yes, i was unaware that hikvision can send images in the alarm stream, but it seems really that, from what i can see in your log. After "BANANA PROCESSING", i log what i received straight from your camera and it is:

15 Dec 16:58:10 - [error] BANANA PROCESSING
--
Content-Disposition: form-data; name="regionEntrance"; filename="regionEntrance"
Content-Type: image/jpeg
Content-Length: 424684
����d

I'll turn on the "region entrance" on one of my camera and i'll see. Please leave me some time.

Supergiovane commented 2 years ago

Hi again i have no camera that have regionEntrance function. Anyway... the memory problem with the EventEmitter can be related to the binary data, but i'm unsure of that. Other than that, i'm not aware on how to increase the emitter.setMaxListeners() in an installation running on iobroker. I don't understand also, where your last log, relating to memory leak, is coming from. There are too many layers (hikvision-ultimate installed on node-red, installed on iobroker, running on node.js). If you are an adventurer, you can try to install node v14 (check if iobroker can run on that first!).

You could also open your camera from internet access, so i can try, but i haven't iobroker, so i cannot reproduce your environment. Please tell me what you wish to do.

Sergio-tix commented 2 years ago

I do not have physical access to the camera, it is far away, I connect to a remote network with cameras via VPN. Or rather: this is the remote network that connects to me via VPN, I have a VPN server with a static IP set up. The network speed to the cameras is very poor, streaming video can only go in the minimum quality and not always. NodeRED is located in the same local network with cameras, and already I connect to NodeRED and look at all the information, there is enough speed for this. I’ll think about how I can arrange for you to access the camera. I want to deal with this problem. Now I will turn off all events in the camera, leave only the "linedetection", two lines, and I will watch. The problem arises only at the time of the event, and the event will occur when people are walking or vehicles are moving. The peak of events I have only from 7:50 to 8:30 and from 12:00 to 14:00 (UTC +03.00), the rest of the time there may be no one, so experiments will not work. I have remote access to Docker. I can install anything there. Which system should I choose? Will Ubuntu work? Which version of NodeRED to install in Ubuntu?

I tried to update and now everything looks like this for me: rr

Supergiovane commented 2 years ago

Hi You can test with a simple raspberryPI or a PC or VM with Debian. Node red will install in just a command line row. It’s very simple. I personally use a Qnap with the virtualization station running a debian with nodered.

Sergio-tix commented 2 years ago

And so, the version of the packages is shown in the screenshot above. In the camera, of all events, only line crossing detection is enabled. And now the event has come, the log is in the archive. iobroker.current.log.zip In the current case, the system did not crash. But again you can see how the camera tried to send the binary. I will try to disable ActiveSearch metadata in the camera.

Hi You can test with a simple raspberryPI or a PC or VM with Debian. Node red will install in just a command line row. It’s very simple. I personally use a Qnap with the virtualization station running a debian with nodered.

I will do it. A little bit later.

Supergiovane commented 2 years ago

Hikvision node simply discards such binary data. I’ll take a look at the log tomorrow.

Sergio-tix commented 2 years ago

My observations of system behavior:

  1. When an event occurs, for example "linedetection", when one object in the frame crosses the line, the camera sends one xml with parameters.
  2. If there was not one object in the frame, but for example two people walking side by side, or one person, but there is also a shadow on the road, which the camera takes for a person, and considers that there are two objects, then the camera sends to each object by one XML. If there are three objects, the camera will quickly send three xml. In each xml only the parameters of one detected object. Thus, this is not one xml with an array of parameters for several objects, but for each object its own separate xml.
  3. If these xml come from the camera more often than once a second - NodeRED crashes, reboots.
  4. According to my observations, the camera can send up to 5-6 XML with binaries of images in one second, when there are many actions, when there are many people. If I understood correctly, the system (my NodeRED system) is not capable of processing data at such a speed. I have no idea how to reduce the speed of the message. Messages from the camera can arrive quickly even if only one event is configured to be detected if there are many people at that moment. If any other detection occurs in parallel at this time, then the situation worsens. In the camera, I did not find any settings on this topic. Let me remind you that I turned off all detections except for line crossing detection. Also disabled all metadata that the camera can transmit to Hikvision registrars. In the camera, I did not find any settings on this topic. Let me remind you that I turned off all detections except for line crossing detection. Also disabled all metadata that the camera can transmit to Hikvision registrars. There is no flashcard in the cell. Recording video and saving snapshots by the camera itself to microsd drives are disabled and have never been used. I have asked a question in the hikvision community. Perhaps someone can tell you what the camera is trying to do and how it can be regulated.
Supergiovane commented 2 years ago

Hi Thanks for the clarification. As far as i can see from the log, the node processes the messages correctly. It simply discards invalid data. About the speed, some Hik with old firmware sends the datastream (even if no movement is detected, just as an Heartbeat), every 250ms. The speed is not a problem here, but i understand that your camera is sending a huge amount of data (because of the embedded images). This can cause some glitches in some library used by... who know? (there are a lot of software involved here). I suggest you to try the "clean way", by installing nodered on an old PC. You can do that at home and connect to the camera via your VPN. This helps you to limit the software environment involved and to obtain a real log (the pure log coming from node-red).

As a beside note... have you tried to use the Alarm node directly, and not the RAW alarm node?

Sergio-tix commented 2 years ago

I have tried using Alarm node, but didn’t figure out the types of notifications until the end, so I used RAW. I will try to use Alarm node directly. I have not used clean yet NodeRED, it is quite difficult to install on Debian, I constantly fly out various errors, several hours of searching for information did not lead to success. As an experiment, I'll try a ready-made image like this: https://registry.hub.docker.com/r/nodered/node-red/ If it is unsuccessful, then I will bet on Raspberry. p.s. What is the reason for ignoring images? Have you tried getting them? You can try to extract them and redirect them to a node for saving to a file or for displaying. On page 91 it is mentioned. There may be a description somewhere else. doku.pub_hikvision-isapi-core-protocolpdf.pdf

Supergiovane commented 2 years ago

Hi Sergio installing on debian is pretty straighforward. Just install node.js (there is an auto installer on github https://github.com/nvm-sh/nvm) and then go to node-red.org (https://nodered.org/docs/getting-started/local) or simply sudo npm install -g --unsafe-perm node-red For autorun, install pm2 package as well.

OR

You can install node-red on Windows PC as well.

Sergio-tix commented 2 years ago

And so - everything is bad. I connected two NodeREDs to the same camera, the same one. One is the one with iobroker. The second is a docker image, pure NodeRED https://registry.hub.docker.com/r/nodered/node-red/. The fall of NodeRED continues. Sometimes both are together. Sometimes only one. There is no dependence, randomly. Yes, in one case, when an event occurs, when three people almost at the same time cross the line, one NodeRED can fall, and the other can work without falling. In another, the same case, another may fall, and the first will work normally. Both can fall at once. Tomorrow I will put NodeRED on Windows, I will continue to observe.

As a beside note... have you tried to use the Alarm node directly, and not the RAW alarm node?

Either I didn’t figure it out, or it doesn’t work correctly. My settings: 1 2

This works, but without considering the direction of travel. Also, the type of object is not taken into account. How to choose parameters so that I can take into account separately people, separately vehicles who have just entered and which have just left? Or is it not yet implemented? p.s. I have not yet tested the system with only "Alarm node" without "RAW node". I will definitely try it later.

Supergiovane commented 2 years ago

Hi Have you tried one of the other Hikvision nodes from other developers? Other than that, i need a log to view something. A log from node-red.

Sergio-tix commented 1 year ago

It's been a long time. I got the stats. My problem persists. I tried different hardware, but the reason was not in the hardware on which Node RED is running. I came to different conclusions. Not Node RED crashes, only the node-red-contrib-hikvision-ultimate application crashes I use Synology Surveillance Station, Hikvision cameras connect by protocol ISAPI. Node-red-contrib-hikvision-ultimate works in parallel with this. The node fall occurs randomly, but the fall never occurred if there were no objects in front of the camera. If people pass with a large interval, for example, one person once a minute, the node crash is very rare. If two or more events occur at the same time or almost simultaneously, for example, there is an vehicle and people in the frame, there is a line crossing event and a zone entry event at once, then the node almost always falls. Here the point is that Synology Surveillance Station also uses the ISAPI protocol, and if in Synology I turn off the "SMART event" for the camera, then the node stops falling. But then Synology does not see events from the camera, it is impossible to record by event. I conclude that there is a conflict. As a result of some conflict falls node-red-contrib-hikvision-ultimate, at the same time, the camera continues to work, and the Synology continues to work and receive events from the cameras. I understand that you do not have time for development node. I saw the information that you are looking for developers. It is unlikely that you will be able to help me, but I will leave this problem here, in case there is a solution.

Supergiovane commented 1 year ago

Hi Sergio Can you please send me a screenshot of your camera, where i can see the lines you draw? I wish to test it. I’m using an intrusion detection area plus a line crossing, without any issue, even if more than one event occur at the same time. Thanks.

Sergio-tix commented 1 year ago

Region1 Region3

Line A -> B Line A-B

Line B -> A Line B-A

The fall of the node occurred, for example, at this moment, when there was a person and a car in the Region, when the car crossed the B-A line and the person crossed the A-B line. Everything almost at the same time. fgbg

But I want to remind you the main thing: there will be no node fall if I disable Synology

Sergio-tix commented 1 year ago

Is it possible to restart only one node? I determine that a node has fallen by events. When a node is running, it constantly sends empty events. If they are not - an alarm. This is a crutch, but it would help me until I understood why the fall occurs.

Supergiovane commented 1 year ago

Ok. Leave me some time to test. I’ve a Qnap so i can test with it. Accessing the alertStream from ISAPI from more than one client at the same time is fair common and should’nt be a problem…

Supergiovane commented 1 year ago

Is it possible to restart only one node? I determine that a node has fallen by events. When a node is running, it constantly sends empty events. If they are not - an alarm. This is a crutch, but it would help me until I understood why the fall occurs.

The camera sends an hearbeat signal, even in case of no events. In old firmware, this heartbeat is sent every 250ms, in the more recent firmwaee, every 10 seconds.

Supergiovane commented 1 year ago

PS: have you updated the node to the latest version?

Sergio-tix commented 1 year ago

Good. I am aware that the problem is elusive. I additionally want to report that the problem is repeated even with just one SMART event. For example, we have only one line crossing, and nothing else. And even in this case, there are falls, although much less often than in the case of many SMART events. I want to emphasize that the problem is precisely when we connect Synology, which also listens to these SMART events. I think you need to test in the direction of multiple parallel requests from the camera. It is possible that Synology itself falls at some point, but I don’t see this, because it quickly resumes work. Or maybe the node does not implement automatic reconnection? After all, if it has fallen, will it endlessly write "waiting for an event" and does not try to reconnect, and will reconnect only when I reboot NodeRED.

PS: вы обновили узел до последней версии?

Yes. Over the course of a year, I tried different versions, different OSes, and the latest NodeRED packages.

Supergiovane commented 1 year ago

Hi in the latest 1.0.70 version, there was the xml2json package, used without a try-catch. That may have caused issues, if the alarmStream from the camera is sent malformed or some udp packet where lost. With the last version, node-red should not crash anymore. Can you please send me the log of the crash, when it occurs, like you've done here https://github.com/Supergiovane/node-red-contrib-hikvision-ultimate/issues/27#issuecomment-994708349 ? I've understood the "Synology" thing... the only issue i see, is a UDP port conflict of some sort.

Supergiovane commented 1 year ago

Sergio, please upgrade to hikvision-ultimate 1.0.71 and let me know.

Sergio-tix commented 1 year ago

I'm quiet because I'm collecting data, checking network devices. You said about the conflict of ports, and I decided to see what was happening on the network. On my network, which is separate for Smart Home devices, There are many homemade products on the basis WT32-ETH01. I was told that if they break down, they can clog the network. Now I'm trying to move the cameras to a separate physical network. As for the logs, there are few of them and they are not informative. The moment of failure:

2023-01-10T13:25:46.720380664Z,stdout,(node:8) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [Parser]. Use emitter.setMaxListeners() to increase limit
2023-01-10T13:25:46.720214219Z,stdout,(Use `node --trace-warnings ...` to show where the warning was created)
2023-01-10T13:25:46.719137883Z,stdout,(node:8) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added to [Parser]. Use emitter.setMaxListeners() to increase limit

I am already convinced that the problem is not in the application. Because it works when it's disabled Synology. I updated to 1.0.71. Many thanks!

Supergiovane commented 1 year ago

Hi Sergio please upgrade to 1.1.0. I've done some code adjustment to try to overcome your issue.

Sergio-tix commented 1 year ago

upgrade to 1.1.0.

Updated. I continue to watch. Thank you!

Sergio-tix commented 1 year ago

With version 1.1.0 for three days no crashes. You have solved my problem. Thank you!

Supergiovane commented 1 year ago

You’re wellcome.