agsh / onvif

ONVIF node.js implementation
https://onvif.pages.dev
MIT License
703 stars 240 forks source link

profileToken problem using stock example.js #49

Closed g40 closed 8 years ago

g40 commented 8 years ago

Running the example using node I get this exception right at start up. It appears to be generated as a result of the initial call to absoluteMove below. How should the profileToken have been set up?

new Cam({
    hostname: CAMERA_HOST,
    username: USERNAME,
    password: PASSWORD
}, function(err) {
    this.absoluteMove({
        x: 1
        , y: 1
        , zoom: 1
    });

though the asynchronous callback system makes this a little difficult to trace.

C:\src\onvif\lib\ptz.js:330
                        '<ProfileToken>' + (options.profileToken || this.activeS
ource.profileToken) + '</ProfileToken>' +

     ^

TypeError: Cannot read property 'profileToken' of undefined
    at Cam.absoluteMove (C:\src\onvif\lib\ptz.js:330:65)
    at null.<anonymous> (C:\src\onvif\example.js:17:7)
    at null.<anonymous> (C:\src\onvif\lib\cam.js:96:13)
    at null.<anonymous> (C:\src\onvif\lib\cam.js:415:13)
    at ClientRequest.<anonymous> (C:\src\onvif\lib\cam.js:193:4)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at Socket.socketErrorListener (_http_client.js:267:9)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)

Any thoughts on this?

RogerHardiman commented 8 years ago

Can you check the value of err before doing the move?

RogerHardiman commented 8 years ago

You can get this error if you cannot connect to the camera (maybe the username, hostname or even the TCP Port are incorrect) I've added some extra code to the example to exit if there is an error.

Moving on from there in theory if you had a static (fixed) ONVIF camera with no PTZ it may connect and then crash in the same place. There should be some form of "if camera has PTZ then send absolute move".

I will see if I can add one as the RPOS project (ONVIF Camera Server) does not implement PTZ

RogerHardiman commented 8 years ago

seems ok with a static ONVIF camera (RPOS) so could have been your IP Address, username, hostname or Port (have added in example to set port in example,js)

g40 commented 8 years ago

Thanks Roger, this is now a lot more stable. I'm going to close this issue.