GuilhermeC18/node-onvif

Error: Network Error: socket hang up

jlegall56 opened this issue · 2 comments

Hello,
I want tu use your code with a sricam camera.

When I test the code for use preset or 'homeposition', I have an error :

The code :

// Create an OnvifDevice object
let device = new onvif.OnvifDevice({
  xaddr: 'http://x.x.x.x/onvif/device_service',
  user : 'user',
  pass : 'password'
});

// Initialize the OnvifDevice object
device.init().then(() => {
  console.log("Connect");
  // The OnvifServicePtz object
  let ptz = device.services.ptz;
  if(!ptz) {
    throw new Error('Your ONVIF network camera does not support the PTZ service.');
  }
  // The parameters for the gotoHomePosition() method
  let profile = device.getCurrentProfile();
  let params = {
    'ProfileToken': profile['token'],
    'Speed'       : 1
  };
  // Send the GotoHomePosition command using the gotoHomePosition() method
  return ptz.gotoHomePosition(params);
}).then((result) => {
  console.log(JSON.stringify(result.data, null, '  '));
}).catch((error) => {
  console.log("> error");
  console.error(error);
});

The response :

$ node preset_test.js  2
myArgs:  [ '2' ]
Connect
> error
Error: Network Error: socket hang up
    at ClientRequest.req.on (/home/user/node_modules/node-onvif/lib/modules/soap.js:168:11)
    at ClientRequest.emit (events.js:182:13)
    at Socket.socketOnEnd (_http_client.js:425:9)
    at Socket.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1092:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Thanks for your help.
Julien
(from France)

Same issue for me also with sricam cameras using the method "gotoPreset". I get the init and profile ok. Any solution?
Thank you very much

Same issue for me also with sricam cameras using the method "gotoPreset". I get the init and profile ok. Any solution?
Thank you very much

Same issue for me also.
Thanks