events not working
ljubomirb opened this issue · comments
I tried with node 6.10, 8.0, 8.1.
I'm not sure if it's related to camera (some clone from china), since I can see events in its manager (some internet explorer activex plugin), but... if someone else also has this problem, then there might be something here to explore...
var CAMERA_HOST = '192.168.1.10',
USERNAME = 'admin',
PASSWORD = '',
PORT = 8899;
var http = require('http'),
Cam = require('onvif').Cam;
new Cam({
hostname: CAMERA_HOST,
username: USERNAME,
password: PASSWORD,
port: PORT
}, function(err) {
if (err) {
console.log('Connection Failed');
return;
}
console.log('CONNECTED');
this.on('event', function(camMessage) { console.log(camMessage) });
});
Error: You should create pull-point subscription first!
at Cam.pullMessages (/home/mm/Downloads/tempp/node_modules/onvif/lib/events.js:137:9)
at Cam._eventPull (/home/mm/Downloads/tempp/node_modules/onvif/lib/events.js:196:8)
at Cam. (/home/mm/Downloads/tempp/node_modules/onvif/lib/events.js:100:12)
at ClientRequest. (/home/mm/Downloads/tempp/node_modules/onvif/lib/cam.js:225:4)
at emitOne (events.js:115:13)
at ClientRequest.emit (events.js:210:7)
at Socket.socketOnEnd (_http_client.js:435:9)
at emitNone (events.js:110:20)
at Socket.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1045:12)
--
and when I remove require ('http') (wich should not be a problem), then error changes to:
TypeError: Cannot read property 'events' of undefined
at Cam._request (d:\moje\pcele\nodetesting\test_onvif3\node_modules\onvif\lib\cam.js:175:16)
at Cam.createPullPointSubscription (d:\moje\pcele\nodetesting\test_onvif3\node_modules\onvif\lib\events.js:87:10)
at Cam._eventRequest (d:\moje\pcele\nodetesting\test_onvif3\node_modules\onvif\lib\events.js:183:14)
at Cam.<anonymous> (d:\moje\pcele\nodetesting\test_onvif3\node_modules\onvif\lib\events.js:170:14)
at emitTwo (events.js:125:13)
at Cam.emit (events.js:213:7)
at _addListener (events.js:248:14)
at Cam.addListener (events.js:298:10)
at Cam.<anonymous> (d:\moje\pcele\nodetesting\test_onvif3\app.js:12:10)
at Cam.<anonymous> (d:\moje\pcele\nodetesting\test_onvif3\node_modules\onvif\lib\cam.js:104:13)
Have you tried with latest from Github? I'm now getting Error: socket hang up
from pullMessages in (events.js) after adding a log for err.
I'm testing with a Reolink RLC-410. Trying to find consistent documentation. I'm seeing examples that say wsa:To must be specified, as well as other formats. New to onvif so still have some more digging to do.
I see the same error:
Error: You should create pull-point subscription first!
Which seems to stem from the createPullPointSubscription() call in events.js which going back further gives an error from the request made, in my case:
ONVIF SOAP Fault: Argument Value Invalid
On my Hikvision gear at least. If I look at the actual request, I'm not sure what is invalid. There certainly isn't much in the body and the rest appears to mainly be auth boilerplate:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken>
<Username>admin</Username>
<Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">xxxxxxxxxxxxxxx</Password>
<Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">nXsBIjyqKGLT2AqWGht/ug==</Nonce>
<Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2018-05-16T22:31:28.780Z</Created>
</UsernameToken>
</Security>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CreatePullPointSubscription xmlns="http://www.onvif.org/ver10/events/wsdl"/>
</s:Body>
</s:Envelope>
Will continue to dig a bit..
Hi James (@Codelica),
Have you ever found a solution for the pull-point subscription error?
Thanks !!
Bart
@bartbutenaers I'm afraid I didn't. Had to move on with some other projects, so this was left on the "someday" list :) Sorry...
Event subscribing is something I'm trying to figure out as well. Why it has to be so complicated?
someone who fixed/improved onvif-event handling may kindly state this here on this thered?
i subscribe now and wait for update...
👍
I have rewritten parts of the events code and it works nicely with Hikvision and Axis equipment.
The new code handles the missing wsa:To field in the XML and subscribes to the pull point first.
Example6.js gives a simple demo.
So I will close this issue report as we have now code for events. Please raise a new report if you still have problems.
Thanks