Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication Error #8

Open
damodaran opened this issue Apr 3, 2019 · 7 comments
Open

Authentication Error #8

damodaran opened this issue Apr 3, 2019 · 7 comments

Comments

@damodaran
Copy link

damodaran commented Apr 3, 2019

I am getting the following error when I tried to run the example code given in the github.
Please find the details given below:

$ node ipnode.js 
Connected to 192.168.20.244:80
Connection closed!
Connected to 192.168.20.244:80
EventNotificationAlert: {"html":{"head":[{"title":["Document Error: Unauthorized"]}],"body":[{"h2":["Access Error: 401 -- Unauthorized"],"p":["Authentication Error"]}]}}
events.js:174
      throw er; // Unhandled 'error' event
      ^

TypeError: Cannot read property 'eventType' of undefined
    at /home/inapp/projects/nodecam/node_modules/node-hikvision-api/hikvision.js:49:48
    at Parser.<anonymous> (/home/inapp/projects/nodecam/node_modules/xml2js/lib/parser.js:303:18)
    at Parser.emit (events.js:189:13)
    at SAXParser.onclosetag (/home/inapp/projects/nodecam/node_modules/xml2js/lib/parser.js:261:26)
    at emit (/home/inapp/projects/nodecam/node_modules/sax/lib/sax.js:624:35)
    at emitNode (/home/inapp/projects/nodecam/node_modules/sax/lib/sax.js:629:5)
    at closeTag (/home/inapp/projects/nodecam/node_modules/sax/lib/sax.js:889:7)
    at SAXParser.write (/home/inapp/projects/nodecam/node_modules/sax/lib/sax.js:1436:13)
    at Parser.exports.Parser.Parser.parseString (/home/inapp/projects/nodecam/node_modules/xml2js/lib/parser.js:322:31)
    at Parser.parseString (/home/inapp/projects/nodecam/node_modules/xml2js/lib/parser.js:5:59)
Emitted 'error' event at:
    at Parser.exports.Parser.Parser.parseString (/home/inapp/projects/nodecam/node_modules/xml2js/lib/parser.js:326:16)
    at Parser.parseString (/home/inapp/projects/nodecam/node_modules/xml2js/lib/parser.js:5:59)
    at Socket.client.on (/home/inapp/projects/nodecam/node_modules/node-hikvision-api/hikvision.js:46:10)
    at Socket.emit (events.js:189:13)
    at addChunk (_stream_readable.js:284:12)
    at readableAddChunk (_stream_readable.js:265:11)
    at Socket.Readable.push (_stream_readable.js:220:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

The code:

var     ipcamera	= require('node-hikvision-api');

// Options:
var options = {
    host	: '192.168.20.244',
    port 	: '80',
    user 	: 'admin',
    pass 	: '1234qwer',
    log 	: true,
};

var hikvision 	= new ipcamera.hikvision(options);

Please let me know what went wrong?

@horendus
Copy link

I'm getting the same error. Any ideas?

@ysnfrk
Copy link

ysnfrk commented May 21, 2019

I was getting the same error. But after I realized that node-hikvision-api uses digest/basic authentication method. Then as you can see below, I changed the authentication method from digest to digest/basic.

image
image

If your error still persists you can use given below code for tracking alarms as I do. This code is taken from node-hikvision-api and I changed it slightly.

cameraEventHandler.zip

@augisbud
Copy link

any patches? I have seen this api being used for node-red and it just crashes the entire service once this happens? Ideas how to fix it? my camera is set to digest/basic, onvif and cgi enabled

@augisbud
Copy link

augisbud commented Jul 11, 2019

11 Jul 13:24:53 - [red] Uncaught Exception:
11 Jul 13:24:53 - TypeError: Cannot read property 'eventType' of undefined
    at /home/pi/.node-red/node_modules/node-hikvision-api/hikvision.js:184:47
    at Parser.<anonymous> (/home/pi/.node-red/node_modules/xml2js/lib/parser.js:303:18)
    at emitOne (events.js:116:13)
    at Parser.emit (events.js:211:7)
    at SAXParser.onclosetag (/home/pi/.node-red/node_modules/xml2js/lib/parser.js:261:26)
    at emit (/home/pi/.node-red/node_modules/sax/lib/sax.js:624:35)
    at emitNode (/home/pi/.node-red/node_modules/sax/lib/sax.js:629:5)
    at closeTag (/home/pi/.node-red/node_modules/sax/lib/sax.js:889:7)
    at SAXParser.write (/home/pi/.node-red/node_modules/sax/lib/sax.js:1436:13)
    at Parser.exports.Parser.Parser.parseString (/home/pi/.node-red/node_modules/xml2js/lib/parser.js:322:31)
    at Parser.parseString (/home/pi/.node-red/node_modules/xml2js/lib/parser.js:5:59)
    at handleData (/home/pi/.node-red/node_modules/node-hikvision-api/hikvision.js:182:9)
    at Socket.<anonymous> (/home/pi/.node-red/node_modules/node-hikvision-api/hikvision.js:47:10)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)

@NetWalkerGit
Copy link

Iam getting same error on node i use node 12.13.0

node cam.js
Connected to 46.252.x.x:81
events.js:187
throw er; // Unhandled 'error' event
^

ReferenceError: self is not defined
at /var/www/html/zoolandie/node_modules/node-hikvision-api/hikvision.js:70:6
at Parser. (/var/www/html/zoolandie/node_modules/xml2js/lib/parser.js:306:18)
at Parser.emit (events.js:210:5)
at SAXParser.onclosetag (/var/www/html/zoolandie/node_modules/xml2js/lib/parser.js:264:26)
at emit (/var/www/html/zoolandie/node_modules/sax/lib/sax.js:624:35)
at emitNode (/var/www/html/zoolandie/node_modules/sax/lib/sax.js:629:5)
at closeTag (/var/www/html/zoolandie/node_modules/sax/lib/sax.js:889:7)
at SAXParser.write (/var/www/html/zoolandie/node_modules/sax/lib/sax.js:1436:13)
at Parser.exports.Parser.Parser.parseString (/var/www/html/zoolandie/node_modules/xml2js/lib/parser.js:325:31)
at Parser.parseString (/var/www/html/zoolandie/node_modules/xml2js/lib/parser.js:5:59)
Emitted 'error' event on Parser instance at:
at Parser.exports.Parser.Parser.parseString (/var/www/html/zoolandie/node_modules/xml2js/lib/parser.js:329:16)
at Parser.parseString (/var/www/html/zoolandie/node_modules/xml2js/lib/parser.js:5:59)
at Socket. (/var/www/html/zoolandie/node_modules/node-hikvision-api/hikvision.js:46:10)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:308:12)
at readableAddChunk (_stream_readable.js:289:11)
at Socket.Readable.push (_stream_readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:182:23)

@EmmanuelSkapple
Copy link

Iam getting same error on node i use node 12.13.0

node cam.js
Connected to 46.252.x.x:81
events.js:187
throw er; // Unhandled 'error' event
^

ReferenceError: self is not defined
at /var/www/html/zoolandie/node_modules/node-hikvision-api/hikvision.js:70:6
at Parser. (/var/www/html/zoolandie/node_modules/xml2js/lib/parser.js:306:18)
at Parser.emit (events.js:210:5)
at SAXParser.onclosetag (/var/www/html/zoolandie/node_modules/xml2js/lib/parser.js:264:26)
at emit (/var/www/html/zoolandie/node_modules/sax/lib/sax.js:624:35)
at emitNode (/var/www/html/zoolandie/node_modules/sax/lib/sax.js:629:5)
at closeTag (/var/www/html/zoolandie/node_modules/sax/lib/sax.js:889:7)
at SAXParser.write (/var/www/html/zoolandie/node_modules/sax/lib/sax.js:1436:13)
at Parser.exports.Parser.Parser.parseString (/var/www/html/zoolandie/node_modules/xml2js/lib/parser.js:325:31)
at Parser.parseString (/var/www/html/zoolandie/node_modules/xml2js/lib/parser.js:5:59)
Emitted 'error' event on Parser instance at:
at Parser.exports.Parser.Parser.parseString (/var/www/html/zoolandie/node_modules/xml2js/lib/parser.js:329:16)
at Parser.parseString (/var/www/html/zoolandie/node_modules/xml2js/lib/parser.js:5:59)
at Socket. (/var/www/html/zoolandie/node_modules/node-hikvision-api/hikvision.js:46:10)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:308:12)
at readableAddChunk (_stream_readable.js:289:11)
at Socket.Readable.push (_stream_readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:182:23)

I get the same error, could you solve that problem?

@ysnfrk
Copy link

ysnfrk commented Feb 18, 2020

Hello,

This issue was related to xml2js library as far as I remember. I did some adjustments to previously shared code but at this moment I could not remember. However, I can make a detailed explanation next week.

cameraEventHandler.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants