Code Monkey home page Code Monkey logo

node-onvif's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-onvif's Issues

400 Bad Request

Hey there,

I am currently trying to control PTZ on a Reolink C1 Pro. I am able to control it using ptzMove() but neither services.ptz.gotoPreset() nor services.ptz.absoluteMove() works for me. Both throw Error: 400 Bad Request.

Please have a look at the following sample code:

let camInstance = new Cam.OnvifDevice({
    xaddr: 'http://192.168.0.1:8000/',
    user: 'admin',
    pass: 'administrator'
});

camInstance.init().then(() => {
    let currentProfile = camInstance.getCurrentProfile();
    camInstance.services.ptz.gotoPreset({
        ProfileToken: currentProfile.token,
        PresetToken: 'test',
        Speed: { x: 1, y: 1, z: 1 }
    }).then((result) => {
        console.log(JSON.stringify(result['data'], null, '  '));
    }).catch((error) => {
        console.error(error);
    });
}).catch((error) => {
    console.error(error);
});

The sample above always ends with the following trace:

Error: 400 Bad Request
    at IncomingMessage.<anonymous> (/Users/julian/WebstormProjects/cctv-bridge/node_modules/node-onvif/lib/modules/soap.js:130:16)
    at IncomingMessage.emit (events.js:215:7)
    at endReadableNT (_stream_readable.js:1183:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

Any hints appreciated!

RTSP instead HTTP

Hello

This project is very amazing and I ran it without any problems in my IP Camera
My all devices support Onvif,

The question is
My IP & Analog cameras are connected to XVR device, Can I access one of XVR channel through XVR ip address?
Or
Can I use rtsp url instead of http in this project?

Another question is:
My devices have two streaming quality (main & extra). Can I choose lower quality?

Thanks a lot

Sending a onvif request from browser

Is it possible to send a onvif request / response straight from the browser without going though node. I would like communicate staright with camera from the browser without going through node.js

fetchSnapshot: Content-Type multiplart/replace

Hi,

some cameras return non image/jpeg content-types for snapshots, for example "multipart/x-mixed-replace;boundary=ipcam264". The content fetched by node.js is still jpeg.
I would like to suggest an option to either ignore the content-type and/or disable the check, or to add a small hack checking for a jpeg marker (ff d8 ff ...) and overwrite the content type with image/jpeg then.

I could provide a pull request if needed

404 not found on fetchSnapshot

Hi,

When I request a snapshot I get 404 Not found error as below (I'm using only example provided in the doc) :

fetching the data of the snapshot...
Error: 404 Not Found
    at IncomingMessage.res.on (/home/zombitch/Developpement/thor/node_modules/node-onvif/lib/modules/device.js:207:13)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1047:12)
    at _combinedTickCallback (internal/process/next_tick.js:102:11)
    at process._tickCallback (internal/process/next_tick.js:161:9)

Regard,
Zombitch

`startDiscovery`と`stopDiscovery`を定期的に実行するとErrorが発生する

setInterval(function() {
  var onvif = require('node-onvif');
  onvif.startDiscovery(function(info) {
    var xaddr = info.xaddrs[0];
    var device = new onvif.OnvifDevice({
      xaddr: xaddr
    });
    device.init(function(error) {
      if(error) {
        console.log('[ERROR] ' + error.message);
      } else {
        console.log(device.address);
      }
    });
    setTimeout(function() {onvif.stopDiscovery();}, 3000);
  });
},5000);

上記コードを実行すると、数回はアドレスを取得するのですが、
2~3回繰り返すと以下のようなエラーで異常終了します。

dgram.js:520
    throw new Error('Not running'); // error message from dgram_legacy.js
    ^

Error: Not running
    at Socket._healthCheck (dgram.js:520:11)
    at Socket.close (dgram.js:414:8)
    at Onvif.stopDiscovery ([proj dir]/node_modules/node-onvif/lib/node-onvif.js:160:12)
    at Timeout._onTimeout ([proj dir]/index.js:15:34)
    at tryOnTimeout (timers.js:228:11)
    at Timer.listOnTimeout (timers.js:202:5)

Callback when PTZ move is finished

I'm trying to move the camera and then take a snapshot, something like below:

const cameraDevice = new onvif.OnvifDevice( params );

cameraDevice
  .init()
  .then( () => {
    cameraDevice.services.ptz
      .absoluteMove( {
        ProfileToken: cameraDevice.getCurrentProfile().token,
        Position: { x: 0.5, y: -0.5, z: 0.1 },
        Speed: { x: 1, y: 1, z: 1 },
      } )
      .then( () => {
        console.log( 'Snap: this should only be called when PTZ has finished moving' );
      } )
  } )

However, I'm the promise for absoluteMove is resolving almost immediately, not when the camera has finished moving, like how I expected.

Anyone knows any workaround to this?

The WebSocket connection was closed

Hi,

thanks for your help.
I now use:
node -v
v4.4.2

I am running on an rasspberry pi 3.

After starting and seeing the UI i get a POP up with:
Error
The WebSocket connection was closed. Check if the server.js is running.

The Server shows:
Listening on port 8880
HTTP : 200 OK : /
HTTP : 200 OK : /style.css
HTTP : 200 OK : /onvif.js

Do you have an idea?

Thanks,
Stefan

setVideoEncoderConfiguration missing

Hi

This library has almost all the capability typically required for onvif usage, except I don't see setting configurations such as setVideoEncoderConfiguration in the code or documentation.

Add support for events

ONVIF supports events, such as motion and sound. Would it be possible to add support for these?

Event service usage

Hi Futomi (@futomi),

I need your help once again ...
My (OnVif) IP camera's have a PIR detector, so I would like to receive events as soon as motion is detected.

Did some reading about it and it seems that WS notifications are being used in OnVif to accomplish this. Can I use perhaps your service-events.js for this purpose?

When I get the available services from my camera, it 'looks' to me that the event service is available:

image

Thanks in advance for your time !!

Bart Butenaers

[ERROR] Failed to initialize the device: Error: Failed to run the GetProfiles() method: Error: socket hang up

Getting this error with a Hikvision camera using this code:

#!/usr/bin/env node

var onvif = require('./lib/node-onvif.js');

// Create an OnvifDevice object
var device = new onvif.OnvifDevice({
  xaddr: 'http://some.host:8080/onvif/device_service',
  user : 'username',
  pass : 'password'
});

// Initialize the OnvifDevice object
device.init((error) => {
  if(error) {
    console.log('[ERROR] ' + error.message);
  } else {
    console.log('The OnvifDevice object has been initialized successfully.');
    // Do something.
  }
});

Sample doesn't support two cameras

I have two IP cameras and can have them both running at the same time through their own GUIs. However, I cannot connect to both from the sample app in this repo. If I'm connected to A, and then open up a new tab and connect to B, the connection to B now works, but A is frozen. Likewise if I reconnect A. Any ideas on what might cause this? (Websockets?) Is it designed to support multiple, or only one?

Error: Network Error: socket hang up

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)

Wrong error format when password or username is wrong

When password or username is wrong i get this error:

Error: Failed to initialize the device: Error: [object Object]
    at services.device.getCapabilities (/home/ano/programmering/rtp test/node_modules/node-onvif/lib/modules/device.js:396:12)
    at promise.then.catch (/home/ano/programmering/rtp test/node_modules/node-onvif/lib/modules/service-device.js:120:4)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)

I would like to get more info then Error: [object Object].
The fix can be found here. Please tell me if this breaks something else! If it does not, then i think this should be fixed.

Quick fix Missing RateControl element in Tenvis cameras

Hi there,

Just wanted to let you know that Tenvis cameras are not sending RateControl data that becomes a reason for your lib to fire an error.

I've fixed the issue through this (code from line 636 and further):

if (p.VideoEncoderConfiguration.RateControl === undefined)
                    {
                        p.VideoEncoderConfiguration.RateControl = {
                            FrameRateLimit: 10,
                            BitrateLimit: 10
                        };
                    }

                    profile['video']['encoder'] = {

"profiles.forEach is not a function" exception

OnvifDevice.prototype._mediaGetProfiles = function(callback) {

....
profiles.forEach((p) => { <== exception

events.js:163
throw er; // Unhandled 'error' event
^

TypeError: profiles.forEach is not a function
at OnvifDevice._mediaGetProfiles.callback.services.media.getProfiles (g:\Nodeproject\onvif\node-onvif\lib\modules\device.js:385:12)
at OnvifServiceMedia.getProfiles.mOnvifSoap.requestCommand (g:\Nodeproject\onvif\node-onvif\lib\modules\service-media.js:312:3)
at OnvifSoap.requestCommand.callback._request.parse (g:\Nodeproject\onvif\node-onvif\lib\modules\soap.js:71:8)
at OnvifSoap.parse.mXml2Js.parseString (g:\Nodeproject\onvif\node-onvif\lib\modules\soap.js:39:3)
at Parser. (g:\Nodeproject\onvif\node-onvif\node_modules\xml2js\lib\xml2js.js:489:18)
at emitOne (events.js:96:13)
at Parser.emit (events.js:191:7)
at SAXParser.onclosetag (g:\Nodeproject\onvif\node-onvif\node_modules\xml2js\lib\xml2js.js:447:26)
at emit (g:\Nodeproject\onvif\node-onvif\node_modules\sax\lib\sax.js:640:35)

-> looks like profiles is not array but object.

with soap message below

"
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex"
xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include"
xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2"
xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2"
xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl"
xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl"
xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics"
xmlns:ter="http://www.onvif.org/ver10/error">
SOAP-ENV:Header</SOAP-ENV:Header>
SOAP-ENV:Body
trt:GetProfilesResponse
<trt:Profiles token="profile1" fixed="true">
tt:Nameprofile1</tt:Name>
<tt:VideoSourceConfiguration token="vsrc1">
tt:NameVideoSource1</tt:Name>
tt:UseCount1</tt:UseCount>
tt:SourceTokenvsrc1</tt:SourceToken>
<tt:Bounds x="0" y="0" width="1280" height="720"></tt:Bounds>
</tt:VideoSourceConfiguration>
<tt:VideoEncoderConfiguration token="venc1">
tt:NameVideoEncoder1</tt:Name>
tt:UseCount1</tt:UseCount>
tt:EncodingH264</tt:Encoding>
tt:Resolution
tt:Width1280</tt:Width>
tt:Height720</tt:Height>
</tt:Resolution>
tt:Quality50</tt:Quality>
tt:RateControl
tt:FrameRateLimit30</tt:FrameRateLimit>
tt:EncodingInterval1</tt:EncodingInterval>
tt:BitrateLimit30</tt:BitrateLimit>
</tt:RateControl>
tt:H264
tt:GovLength30</tt:GovLength>
tt:H264ProfileBaseline</tt:H264Profile>
</tt:H264>
tt:Multicast
tt:Address
tt:TypeIPv4</tt:Type>
tt:IPv4Address0.0.0.0</tt:IPv4Address>
</tt:Address>
tt:Port0</tt:Port>
tt:TTL0</tt:TTL>
tt:AutoStartfalse</tt:AutoStart>
</tt:Multicast>
tt:SessionTimeoutPT60S</tt:SessionTimeout>
</tt:VideoEncoderConfiguration>
</trt:Profiles>
</trt:GetProfilesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>"

Error: Cannot find module 'node-onvif'

Hi,
when i execute node, i get the following issue:

server01 ~ # node /tmp/node-onvif/sample/manager/server.js
module.js:550
    throw err;
    ^

Error: Cannot find module 'node-onvif'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/tmp/node-onvif/sample/manager/server.js:8:10)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
server01 ~ # 

node-onfiv is installed:

server01 ~ # npm list
[email protected] /root
├─┬ [email protected]
│ └─┬ [email protected]
│   ├── [email protected]
│   ├── [email protected]
│   ├─┬ [email protected]
│   │ ├── [email protected]
│   │ ├── [email protected] deduped
│   │ ├── [email protected]
│   │ ├── [email protected]
│   │ ├── [email protected]
│   │ ├─┬ [email protected]
│   │ │ └── [email protected] deduped
│   │ └── [email protected]
│   └── [email protected]
└─┬ [email protected]
  ├── [email protected]
  └── [email protected]

server01 ~ #

Where is my fail?

Discovery Packets can not be sent due to this._udp being null

For some reason, sending some discovery packets is taking a couple seconds before they actually go out and invoke the next one. This means if the discovery is stopped (via setTimeout) in between the packets, then this._udp will already be null. The next packet can not be sent and throws an (uncatchable) error ("TypeError: Cannot read property 'send' of null" at line 214) instead.
let send = () => {...} is simply missing a check if this._udp ist still set properly.

I think it can easily be reproduced by setting _DISCOVERY_WAIT smaller than _DISCOVERY_RETRY_MAX * _DISCOVERY_INTERVAL * 3.

SOAPの応答の`Scopes`に属性が指定されていた場合エラーとなる。

SOAPの応答のXML内で、Scopesに属性が指定されていることがある。

<SOAP-ENV:Envelope (略) xmlns:wsd="http://schemas.xmlsoap.org/ws/2005/04/discovery" (略)>
(略)
<wsd:Scopes MatchBy="http://schemas.xmlsoap.org/ws/2005/04/discovery/rfc3986">(略)

この場合、
https://github.com/futomi/node-onvif/blob/42449b0e31c147d3463e8d9408489aa447effdfb/lib/node-onvif.js#L59
probe_match['Scopes']xml2jsの仕様によりオブジェクトを返すため、
scopes = probe_match['Scopes'].split(/\s+/);splitで落ちる。

Image Profile Setting

Hi,
I successfuly use your fantastic project to control the PTZ of 2 cameras: RLC 423 and SD22204T GN
But my Dahua SD22204T GN hasnt got IR Led so i've got a night profile, a day profile and a normal profile.
These profile control brightness, contrasts etc.
But i can't see them with your project.
I tried all commands but nothing seems to give me these image settings.
I've found this but it isn't supported with your package
https://www.onvif.org/specs/srv/img/ONVIF-Imaging-Service-Spec-v210.pdf
Have you got an idea
Thank You.
Jules

Failed to initialize the device

Hello,

I got this:
Failed to initialize the device: Error: Networ Error: socket hang up at services.media.getProfiles (node_modules\node-onvif\lib\modules\device.js:464:12) at promise.then.catch (node_modules\node-onvif\lib\modules\service-media.js:392:4) at<anonymous>

I try to launch example of Create OnvifDevice object:

'const onvif = require('node-onvif');
// Create an OnvifDevice object
let device = new onvif.OnvifDevice({
xaddr: 'http://IP:PORT/onvif/device_service',
user : 'xxxx',
pass : 'xxxx'
});

// Initialize the OnvifDevice object
device.init().then((info) => {
// Show the detailed information of the device.
console.log(JSON.stringify(info, null, ' '));
}).catch((error) => {
console.error(error);
});'

It gives me this error when I try to launch it on Windows Server 2012, but when I launch it on my pc (Win 10), it works fine. I tried to turn off firewall, make in and outbound rules, with no success. The camera has public is behind router and has forwarded ports.
Any help is appreciated.

EDIT So it turned out, that it doesn't work on my local pc either. It was connecting to my LAN IP cam, even though I typed IP address of public IP camera.
EDIT2 It is getting stranger, and stranger. When I my local IP cam connected to router, the app can connect both to local, and public IP cam (I can tell by Hardware ID), but when I disconnect local IP camera, it suddenly can't connect to public camera. When I try snapshot app and type public IP it gets snapshot...from local IP camera.

How to set Default videoSourceConfiguration and videoEncoderConfiguration

Hi,
I'm pretty new to onvif protocol. I have the following requirements:-

  1. Change default video source config (I hope setVideoSourceConfiguration may be helpful here), where I want to change the camera's default resolution and FPS. (For streaming and everything else).

  2. I want to record camera streaming at multiple resolutions (let's say 1920x1080, 720x480, etc) and FPS, how to do that? (I guess I need to create a new profile with required videoEncoderConfiguration). Is that right?

  3. I want to change the camera's default contrast, saturation, hue, and other images params and for a particular profile. Which method do I need to use?

Thanks in advance.

Handle Digest On Fetch Snapshot Issue

When I access the snapshot URL through a browser the following digest is sent and works:

Digest username="root", realm="AXIS_WS_ACCC8E494578", nonce="/QcV7p11BQA=2e07815dfad0fe310a9c42609dc869e920fb0efc", uri="/onvif-cgi/jpg/image.cgi?resolution=1280x720&compression=30", algorithm=MD5, response="a873fc750b676f59586b8d758d8ac22e", qop=auth, nc=00000001, cnonce="1c8a3e9fb1c1b19b"

When the node-onvif encounters the same issue the following digest is sent an http status of 401 is returned:
{"date":"Tue, 11 Sep 2018 20:22:17 GMT","server":"Apache/2.4.27 (Unix) OpenSSL/1.0.2k","www-authenticate":"Digest realm="AXIS_WS_ACCC8E494578", nonce="t6fuOp51BQA=f644e559881cb59b13221e8f9b63747f39e342c7", algorithm=MD5, qop="auth"","content-length":"381","connection":"close","content-type":"text/html; charset=iso-8859-1"}

Different values - would expect the content to be similar. Any ideas?

Tim McClure

Enhancement: Consider passing in a port with address

All the ONVIF cameras I have worked with allow the User to change the port to access the device. I think it would be great if the port (optional: default 80) could be passed in at the same time as the address.

async problem?

I am using your library to fetch a snapshot from multiple cameras at once and save them to the local filesystem.
Sometimes it is just working fine, sometimes I have the problem that the same image from the same camera is saved in the wrong file.

I am assuming I've did something wrong with the async function or something similar, so I am looking for help here. :)

const` onvif = require('node-onvif');
const fs = require('fs');

async function kamera_screenshot(ip) {
    let device = new onvif.OnvifDevice({
        xaddr: "http://" + ip + "/onvif/device_service",
        user : 'admin',
        pass : 'admin'
    });
    device.init().then(() => {
        return device.fetchSnapshot().then((res) => {
            fs.writeFile("/tmp/" + ip + ".jpg", res.body, {encoding: 'binary'}, function (fd, err) {
                if (err) throw err;
            });
        });
        });
    return;
}

kamera_screenshot("192.168.0.1");
kamera_screenshot("192.168.0.2");
kamera_screenshot("192.168.0.3");
kamera_screenshot("192.168.0.4");

So, in this example, I have two pictures from camera 192.168.0.1 in the 192.168.0.1.jpg AND 192.168.0.2.jpg (or any other combination)

Xampp server

Hi do you work with xampp server? I could not run

PTZ Test failed on D-Link DCS 5222L B

1) PTZ Test on D-Link DCS 5222L B

  • using node v6.12.2 (npm v3.10.10) or
  • using node v7.10.0 (npm v5.6.0):

"Manufacturer": "D-Link Corporation",
"Model": "DCS-5222LB",
"FirmwareVersion": "2.14.04",

PTZ test non passed. It returns Done without moving/tilting/zooming the camera.

XML in 192.168.x.x/onvif/device_service:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1">
<SOAP-ENV:Body>
<SOAP-ENV:Fault SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>
End of file or no input: Operation interrupted or timed out
</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

2) ONVIF Network Camera Manager

  • works using node v4.8.7 (npm v2.15.11)
  • works using node v6.12.2 (npm v3.10.10)
  • does not work using node v7.10.0 (npm v5.6.0):
Socket.prototype.__proto__ = EventEmitter.prototype;
TypeError: Cannot read property 'prototype' of undefined

[Question] Exception catching

Hi. I'm building a nodeJS application using node-onvif to track some cameras. I have a situation where I'm looping over a couple of times over device.fetchSnapshot() in order to parse the results for my scenario.

From time to time, I'm getting an error that I cannot track down.

ERROR Error: Uncaught (in promise): 11552024 - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.

My code is written Promise style:

this.device.fetchSnapshot() .then(async (res) => { // my code });

I tried adding a catch statement, but the scenario is the same. I tried using try {} catch, but it seems to just hang if this error is thrown.

Unfortunately it doesn't happen all the time (I reckon from time to time, due to the looping over fetchSnapshot() the camera doesn't return a response or something breaks, thus the error.)

Any ideas ?

Can not start server.js, SyntaxError: Unexpected token >

node ./server.js

/home/pi/node_modules/node-onvif/sample/manager/server.js:118
onvif.startDiscovery((device) => {
^
SyntaxError: Unexpected token >
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

node -v
v0.10.29

npm -v
1.4.21

Thank you,
Stefan

name space handling (xmlns:)

I think this library suffers from the same problem that onvif had; namely that when the camera is sending xmlns: name spaces with all of its elements, the xml to json parser is not doing the right thing. My camera outputs something like this:

<tt:Uri xmlns:tt="http://www.onvif.org/ver10/schema">http://169.254.72.162:8081/web/snapshot.jpg</tt:Uri>

Which produces json that looks like this:

    "snapshot": {
      "_": "http://169.254.72.162:8081/web/snapshot.jpg",
      "$": {
        "xmlns:tt": "http://www.onvif.org/ver10/schema"
      }
    },

If I apply the same "fix" as described in the linked ticket, namely:

soap = soap.replace(/xmlns(.*?)=(".*?")/g,'');
mXml2Js.parseString(soap, opts, (error, result) => {
...
});

in lib/modules/soap.js::parse(), then the problem goes away and I get this json:

    "snapshot": "http://169.254.72.162:8081/web/snapshot.jpg",

I realize this is just how xml2js works, but higher level apps (like samples/manager) break when the camera is sending xmlns:

Multiple ethernet/wifi cards prevent device discovery

Hello, my laptop has three ethernet connections: 1 wired, 1 wifi, and 1 wifi direct to a miracast display. If the miracast connection is active, device discovery fails: it reports 0 devices found. However, if I disable the miracast display, which removes the wifi direct connection, discovery works properly and reports the ONVIF devices present on the network.

Is there a way to list the ethernet connections which are present, and then to specify which connection to use for sending the multicast/discovery packets?

Table layouts on readme page

Hi @futomi,

Thanks for this great piece of software!

A very minor issue with the tables on the README page, that are a bit messed up:

image

I have it on Chrome, Edge and Firefox. So it seems not to be a browser specific layout problem.

Kind regards,
Bart Butenaers

fetchSnapshot socket hang up error

Hi,
i'm testing node-onvif with a Vitorcam CA-31.

All works properly (discovery, get profile, change profile, get info ...) but fetchSnapshot fails with

{ Error: socket hang up
at createHangUpError (_http_client.js:331:15)
at Socket.socketOnEnd (_http_client.js:423:23)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9) code: 'ECONNRESET' }

it seems as cam close connection, what's happening ?

Multiple Network Interfaces

I have a machine with multiple network interfaces.

For UDP Datagrams the Node Documentation states for socket.bind([port][, address][, callback]):
"If address is not specified, the operating system will attempt to listen on all addresses. "

Notices the word "attempt." They may "attempt" to do that in the case of your software implementation, but it appears their "attempt" failed.

If I modify the code in Onvif.prototype.startProbe = function(callback) {

To make it look like this:

this._udp.bind(null, "10.1.254.55", () => {
			this._udp.removeAllListeners('error');

Where the desired interface is at "10.1.254.55", the software can find cameras, etc.

We could plagiarize the "onvif" package (their _udp socket is called socket) to provide options for discovery/probe (note that Array.prototype.some probably only calls bind once, but the end result is that the socket is indeed bound to an interface that seems to work):

if (options.device) {
	var interfaces = os.networkInterfaces();
	// Try to find the interface based on the device name
	if (options.device in interfaces) {
		interfaces[options.device].some(function(address) {
			// Only use IPv4 addresses
			if (address.family === 'IPv4') {
				socket.bind(null, address.address);
				return true;
			}
		});
	}
}

Note that the "10.1.254.55" above is the value of address.address from the other onvif package.

can i snapshot multiple ip cam addrs by looping from array?

const onvif = require('node-onvif');
const fs = require('fs');

let yuhu=['http://192.168.57.11/onvif/device_service',
'http://192.168.57.12/onvif/device_service',
'http://192.168.57.13/onvif/device_service',
'http://192.168.57.14/onvif/device_service'
,'http://192.168.57.15/onvif/device_service']

for (i = 0; i < yuhu.length; i++) {

// Create an OnvifDevice object
let device = new onvif.OnvifDevice({
xaddr: yuhu[i],
user : 'admin',
pass : 'xxxx!!!'
});
// Initialize the OnvifDevice object
device.init().then(() => {
// Get the data of the snapshot
console.log('fetching the data of the snapshot...');
return device.fetchSnapshot();
}).then((res) => {
// Save the data to a file
fs.writeFileSync('s'+i+'.jpg', res.body, {encoding: 'binary'});
console.log('sDone!');
})
.catch((error) => {
console.error(error);
});
}

TypeError: Cannot read property 'Width' of undefined

Using this example code below and of course changing the IP and login info

const onvif = require('node-onvif');

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

// Initialize the OnvifDevice object
device.init().then((info) => {
  // Show the detailed information of the device.
  console.log(JSON.stringify(info, null, '  '));
}).catch((error) => {
  console.error(error);
});

I get the folowing response from a camera

The OnvifDevice object has been initialized successfully.
{
  "Manufacturer": "Honeywell",
  "Model": "H4D2F",
  "FirmwareVersion": "42.0.7",
  "SerialNumber": "00000",
  "HardwareId": "DM368"
}

when I try with a newer version of the camera I get this

Error: Failed to initialize the device: TypeError: Cannot read property 'Width' of undefined
    at services.media.getProfiles (/home/user/node_modules/node-onvif/lib/modules/device.js:464:12)
    at promise.then.catch (/home/user/node_modules/node-onvif/lib/modules/service-media.js:392:4)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

I was wondering what info might be needed to help this issue.

Thanks

RTSP backchannel for two way audio

Hi, y'all!

I'm doing some preliminary research into building out a CCTV system for my home using ONVIF capable cameras. I'm looking at adding a few cameras that support 2-way audio, like an intercom.

I'm new to this, but it seems that the cameras that support ONVIF and two way audio (like an intercom) do so using a RTSP backchannel.

It's my understanding correct?

Is this possible with the current library? If not, is it something you'd be interested in seeing in a PR?

The action requested requires authorization

Despite using correct URL and credentials (username + password), the connection to IPCam fails:

Error: Failed to initialize the device: Error: 400 Bad Request - The action requested requires authorization and the sender is not authorized
    at services.device.getDeviceInformation ([...]/node_modules/node-onvif/lib/modules/device.js:453:12)
    at promise.then.catch ([...]/node_modules/node-onvif/lib/modules/service-device.js:853:4)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.