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

Cannot read property 'profileToken' of undefined #119

Closed
strarsis opened this issue Sep 23, 2019 · 7 comments
Closed

Cannot read property 'profileToken' of undefined #119

strarsis opened this issue Sep 23, 2019 · 7 comments

Comments

@strarsis
Copy link

When trying to connect to the camera an error occurs:

TypeError: Cannot read property 'profileToken' of undefined
    at Cam.getStreamUri ([...]node_modules/onvif/lib/media.js:802:67)
    at Cam.<anonymous> ([...]index.js:11:8)
    at Cam.<anonymous> ([...]node_modules/onvif/lib/cam.js:128:19)
    at Cam.<anonymous> ([...]node_modules/onvif/lib/media.js:729:14)
    at parseSOAPString ([...]node_modules/onvif/lib/utils.js:98:3)
    at IncomingMessage.<anonymous> ([...]node_modules/onvif/lib/cam.js:206:4)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
@strarsis
Copy link
Author

Apparently I used incorrect ONVIF credentials (used Web UI credentials instead).
But instead a proper error should be thrown that authorization failed.

@agsh
Copy link
Owner

agsh commented Oct 29, 2019

@strarsis It seems that your cam sends a response for the getCapabilities method even with the wrong credentials or it hasn't got any active source.
You can check cam.activeSources property before calling any media method. Also, I've added a new event warning in the master branch. So you can check this trouble by subscribing:

cam.on('warning' msg => { console.warning(msg); });

agsh added a commit that referenced this issue Oct 29, 2019
agsh added a commit that referenced this issue Oct 29, 2019
agsh added a commit that referenced this issue Oct 29, 2019
@dcruveiller
Copy link

Hey i have also this problem and i'm sure i put the right login and hostname informations.
Here is my output:

/Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/onvif/lib/media.js:1003
                                '<ProfileToken>' + (options.profileToken || this.activeSource.profileToken) + '</ProfileToken>' +

TypeError: Cannot read property 'profileToken' of undefined
    at Cam.getStreamUri (/Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/onvif/lib/media.js:1003:67)
    at Cam.<anonymous> (/Users/d.cruveiller/Documents/TIB/vscode/onvif/app.js:10:10)
    at Cam.<anonymous> (/Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/onvif/lib/cam.js:159:20)
    at Cam.<anonymous> (/Users//d.cruveiller/Documents/TIB/vscode/onvif/node_modules/onvif/lib/cam.js:365:14)
    at parseSOAPString (/Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/onvif/lib/utils.js:108:3)
    at IncomingMessage.<anonymous> (/Users//d.cruveiller/Documents/TIB/vscode/onvif/node_modules/onvif/lib/cam.js:267:4)

of this code:

var Cam = require('onvif').Cam;

new Cam({
    hostname: '192.168.1.78',
    username: 'admin',
    password: 'admin'
  }, function(err) {
    // if (err) { console.log(err); return; }
    // this.absoluteMove({x: 1, y: 1, zoom: 1});
    this.getStreamUri({protocol: 'RTSP'}, function(err, stream) {
        console.log("CONNECTED");
    });
});

But if i uncomment the // if (err) { console.log(err); return; } I get:

Error: Wrong ONVIF SOAP response
    at /Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/onvif/lib/utils.js:74:15
    at Parser.<anonymous> (/Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/xml2js/lib/parser.js:308:18)
    at Parser.emit (events.js:315:20)
    at SAXParser.onerror (/Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/xml2js/lib/parser.js:123:26)
    at emit (/Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/sax/lib/sax.js:624:35)
    at error (/Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/sax/lib/sax.js:653:5)
    at strictFail (/Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/sax/lib/sax.js:677:7)
    at beginWhiteSpace (/Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/sax/lib/sax.js:951:7)
    at SAXParser.write (/Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/sax/lib/sax.js:1006:11)
    at Parser.exports.Parser.Parser.parseString (/Users/d.cruveiller/Documents/TIB/vscode/onvif/node_modules/xml2js/lib/parser.js:323:31)

@qaz6209031
Copy link

Same issue here, I am sure I put the right hostname and authentication information, but I got the same result.

@Roulbac
Copy link

Roulbac commented Jan 26, 2021

Same here

@ricmoo
Copy link

ricmoo commented Jun 23, 2022

FYI. This is was happening to me because the port was incorrect. My camera uses 8080 by default, and that made everything move along swimmingly. :)

@distante
Copy link

Maybe this helps someone, I got this error because I was using http://123.my.camera.ip, and I should just use 123.my.camera.ip

This issue was closed.
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

8 participants