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
51 stars 11 forks source link

Node-red stops after UnhandledPromiseRejectionWarning #27

Closed djivkov closed 2 months ago

djivkov commented 3 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 months ago

Sorry, THIS FILE hikvisionUltimateAlarmRaw.js.zip

Sergio-tix commented 2 months ago

Sorry, THIS FILE hikvisionUltimateAlarmRaw.js.zip

Judging by the hashes, my file in the system is absolutely the same as the one you sent.

Supergiovane commented 2 months ago

La stanchezza. Here the right file. Hikvision-config.js.zip

Sergio-tix commented 2 months ago

image Yes. Now the snapshot comes in text form. At least part of it. This text is similar to the text that the camera creates in the vault. I allocated disk space to the camera on NAS (CIFS). Set up the camera to take a snapshot when certain events occur. Now she takes pictures and stores them on a network share. And they don't look like a normal picture. It looks like this: File "hiv00000.pic" In which:

`{ "HeadInfo": { "version": 2, "operate": "get", "intelligentType": "smartEvent", "eventType": "lineCross", "intelligentVersion": 1, "channel": 1, "subVersion": 20200413 }, "BodyInfo": { "relativeTime": -1428157859, "absTime": 1650789376, "millisecond": 165, "uuid": "03b3c234-5b19-4ab3-a8ba-cdcce044f126", "bodyType": "Alarm", "Alarm": [{ "alert": true, "viewState": 0, "RuleInfo": { "id": 1, "ruleType": "lineType", "RuleParam": { "direction": "left_to_right" }, "PointF": [{ "x": 0.44769874215126038, "y": 0.40000000596046448 }, { "x": 0.44769874215126038, "y": 0 }] }, "TargetInfo": { "targetType": 1, "id": 48860, "alarmFlg": false, "confidenceLevel": 3, "Rect": { "x": 0.44062501192092896, "y": 0.0555555559694767, "w": 0.02265625074505806, "h": 0.11388888955116272 } } }], "PicInfo": [{ "picType": "backgrdPic", "picLen": 280819 }] } }яШяа – [id:48860] [type:1] [rule_id:1] [event_type:1] [jpgQ:80] [tgt rect:0.4406(564), 0.0556(40), 0.0227(29), 0.1139(82)] [alert time:2024-9-18 16:48:0] яЫ „  

 %# , #&')*)-0-(0%()(  

(((((((((((((((((((((((((((((((((((((((((((((((((((яА Р " яДў  
  } !1AQa"q2Ѓ‘Ў#B±БRСр$3br‚ %&'()456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzѓ„…†‡€‰Љ’“”•–—˜™љўЈ¤Ґ¦§Ё©ЄІіґµ¶·ё№єВГДЕЖЗИЙКТУФХЦЧШЩЪбвгдежзийкстуфхцчшщъ  
  w !1AQaq"2ЃB‘Ў±Б #3RрbrС $4б%с&'()
56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ѓ„…†‡€‰Љ’“”•–—˜™љўЈ¤Ґ¦§Ё©ЄІіґµ¶·ё№єВГДЕЖЗИЙКТУФХЦЧШЩЪвгдежзийктуфхцчшщъяЭ  яЪ   ? ъh xLэ)бBр “UЇnD0ЛыЕG€ИRxьi№КяРх/O3G$XЅъHc•¦9fб‚ЮqґaёщIдЧ%ЁjR^K ZЋ«'цX›М-$9•О,КwБ@юIАиµ[ЅSыf№kuЭТ1;VB%¶В„mњЊ:’И=zуђэ·J†КюТk(ҐђH›boхeTЁU<дf5Пx‘“U­я Ї#6»џяСкьAє±ЅѕIоK М%Ы©»pf‹ о;Рњ*ᘜ6sYй04 XЗеy®ZlЎe1Ќ¤Ћ„дсБаЂq^пч±BђЩЙfа…Ь2›s”Ъr~о2=>чbEgЬ\K%УЬјЄтєтБёaќёъOzЦiњнЈяТІУЬZDЦввE ‰|¤—r+mЖн¬xfдр8 =Єњ—SµБ”МеЩJNr¤Ћ{в©оlгљ~sу(Ж+§—[ґr6яУ¬НБЁъRЏ˜е‰ь(ЫЧФqџяФў5<mґеqУ їQЕUN}iкxъЧK9S?яХ„ЖљЩ$гЉЏuзЊЦЗ1яЦ¤OУ4gп‘лЉ#‰з‘cЊe‰З'§Ц˜ЩYr2§µОTяЧўw(RАб†F{ХДІуtЦё]Ы”9 Ћ=j¤уI;щ’9v<хЄхЭє­”0G1y‡&-Ы№г#ЫџеSZRЊUґf1KSяРЎ пm»¶®~fN?hx…I,FЮ”•ЪHR{qЯ­«$Є§?0П8ъЉ®n¦<§яСМ(IапLь8O9Ћ>cЙН@Э=«Dф9љмяТКCњbЇГ@ rz «igфљ»њњЦ“vZБ\яУglљbЊ·µ=›#Ґ;E+Ш-}OяФ†RqTe|љћжAНQvжњu3“?яХВb0M0а’Oт§—зҐ+њ0Ж ­vяЦзЩ°lУ ЪњэоХ! °&ўlИД…вµ^G/©яЧжWњsНJЯ4А1О9§ѓиkЄ18Ы?яРВЌw7=&¤ЮI<азЏjfJB3ьЗйژя )Ааꫦ‡ яСГ<Љ‰сџТҐм П5 sњWlv8яТжЩ{УHКУКџ,сQг#ЇjфяУеі@з8ПЇРТdџё™З­;‡б]QzбEwу#‹•џяФжA8$UхО6Фlц꤉T·e6=ЄeТГ.йдnЩ©юЗ  ©lњqО=л»™ф8щVяХд…К)эФo'^јRGц©ЙЊсУ?ОµЉ¤gCжа *ЦFKЁ‹рзф®пxгґяЦжОоSуМUG8S·щTсi Ђdзс«2О~]КAфХIob?y"¶p<їЧъWaКќѕяЧГ›O‚(XнP@к{S’Х…ЁbTЖаxЛ~j…ХМеv2ђќ2зЇ­iБ{ЩB/!€eзaћ‚»“vgII+џяРжQ;;t ‘ЃП9Зф«±Е EµTыЫ›їгQ[ Щї<їНS3ЃПёНtЬз?яСА’ТЭ‰iLЋЄҐUє±6С6ю Єщl›ЄѓЕA, $\IµЃщWЄю"єьЋVяТг2ҐЩ‘›еqޘІ#фК˜х5rpPьл°я }9_м¬щ;‘»ьјWMЋSяУгФ¶Т °лЧрЄІП~xдгa2бN:wўhе0д¬…єЃ[lО3яФаКь‹Ћ{ТЕf6Ке№щІ•3e[9оEH­‘•Pky=&ПяХа¤·@§ЄфGхЕ ‹жКtЗCO, оb^ќЅ©ЂФхюµ­О5&яЦуФILя &жnшз5y‘em’ YНтъzљЌ\щLЃШЁЗ_Jіo0 ±Д¬$8Q“ЫЯт­dоq¶яЧд<¦pBЕЖN .......

And so, one by one, all the snapshots in this one file. When requested through the camera interface, it extracts the image from this file and returns it in normal form with the extension .jpg the output content of the node is very similar to the data in the file. I need some time, I will try to make an image from the text. Thank you!

Supergiovane commented 2 months ago

It seems to mix the jpeg stream data with the camera settings. The content is clearly not an image as i expect. On the ISAPI documentation, there is nothing about the data format. I need to guess it by trying to decode the stream data. I'll let you know...

Supergiovane commented 2 months ago

I have no cameras capable of sending the image embedded into the eventsteam. If you could send me a file (zipped) with the Content-Type: image/jpeg, i will work on that.

Sergio-tix commented 2 months ago

I have no cameras capable of sending the image embedded into the eventsteam. If you could send me a file (zipped) with the Content-Type: image/jpeg, i will work on that.

I started sending this text data to a file. But somewhere the message is cut off and I get only 20-60KB, when the actual size should be around 400KB. image

Here they are. payload.zip

I can offer other information that may be useful. I set up automatic saving of snapshots to a network drive. All information is stored in the file: hiv00000.pic hiv00000.zip In the camera's web interface, saved snapshots look like this: image

And these are snapshots if you request their unloading from the camera 2024-09-19.zip If you open the file hiv00000.pic in a text editor, and open the file .jpg in a text editor, you will find a lot in common. It also looks like the text returned in "payload"

Supergiovane commented 2 months ago

There is some extra data in the jpg, that must be wiped out. Thanks for the zip files, i'm analyzing it.

Supergiovane commented 2 months ago

Hi are you able to give me access to the camera, so i can deal with it directly? I need the full event request, with for-data multiparts etc... and i cannot quess it.

Sergio-tix commented 2 months ago

I need to think about how to do this. The camera is on a network that does not have internet access. I access this network through a VPN. I'll come back with an answer a little later.

Supergiovane commented 2 months ago

...or another camera you have on hands, capable of sending the image toghether with the event stream...

Sergio-tix commented 2 months ago

...or another camera you have on hands, capable of sending the image toghether with the event stream...

It wasn't easy for me, but I think I managed to set up my Mikrotiks How can I provide you with information in a confidential manner? email?

Supergiovane commented 2 months ago

Thank you! The connection is working. Now i can work to the payload. I'll let you know.

Supergiovane commented 2 months ago

..just to let you know that i'm actively working on extracting the image from a multipart/form-data message...

Supergiovane commented 2 months ago

...it takes a little long, because i must wait for someone to trigger the event, everytime i do a change in the code...

Sergio-tix commented 2 months ago

You will have as much time as you need. There will be very few events now and they will be rare. Many events happen on weekdays from 12:00 to 15:00 local time. And around 8 am.

Supergiovane commented 2 months ago

Hi Sergio Almost done. Here an image captured by the node.

97f3adf213734e4d3dae9e3d85965e76_jpg_e_GitHub
Supergiovane commented 2 months ago

Hi Sergio node-red-contrib-hikvision-ultimate@1.2.0-beta.1 is out As this is a beta, you need to cd into your ./node-red folder and type npm install node-red-contrib-hikvision-ultimate@1.2.0-beta.1 Let me know if it fits your needs.

Node-RED___Flow_1
Supergiovane commented 2 months ago

1.2.0 official is out.

Sergio-tix commented 2 months ago

This works great! Just what need! Now can get exactly the shots that the camera analytics thought needed, without delay. Thank you!