agsh / onvif

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

two callbacks fired with getRecordings #53

Closed RogerHardiman closed 8 years ago

RogerHardiman commented 8 years ago

Recently there was a change in lib/cam.js so that it fires a callback if there is a connection error from the camera.

When I call getRecordings on an NVT that does not support Profile G I now get two callbacks, the first being a callback with ECONNRESET and the second being a callback with 'Wrong ONVIF SOAP response'

The proper operation would be to check if getCapabilities lists a recording service.

But in this situation I was only expecting one callback to be fired.

Should we change lib/cam.js so that after the ECONNRESET callback, the value of callback is cleared so that the callback function is not executed a 2nd time.

Thanks

agsh commented 8 years ago

Strange, it can't happen. I've added one more check to cam.js into dev branch. Please check it. 01b11f05b5c2262cc1ea31f2ce6e7f2a952a3b42

RogerHardiman commented 8 years ago

I have seen your fix in the dev tree and changed it slightly so that is resolves my problem.

The problem is created by calling getRecordings on a Bosch encoder (that does not implement getRecordings) while supplying an invalid username and password.

req.on('error') is triggered and also and res.on('end') is triggered and this was the cause of the 'double callback'

RogerHardiman commented 8 years ago

Fixed in dev branch with fc0d03dc