Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/cam.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ var Cam = function(options, callback) {
this.preserveAddress = options.preserveAddress || false;

this.events = {};
this.events.timeout = options.eventsTimeout || this.timeout;
setImmediate(function() {
this.connect(callback);
}.bind(this));
Expand Down Expand Up @@ -184,7 +185,7 @@ Cam.prototype._request = function(options, callback) {
, path: options.service
? (this.uri[options.service] ? this.uri[options.service].path : options.service)
: this.path
, timeout: this.timeout
, timeout: options.timeout || this.timeout
};
reqOptions.headers = {
'Content-Type': 'application/soap+xml'
Expand Down Expand Up @@ -215,7 +216,7 @@ Cam.prototype._request = function(options, callback) {
});
});

req.setTimeout(this.timeout, function() {
req.setTimeout(options.timeout || this.timeout, function() {
if (callbackExecuted === true) {
return;
} else {
Expand Down
4 changes: 3 additions & 1 deletion lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,13 @@ module.exports = function(Cam) {
sendXml += '</s:Header>' +
'<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' +
'<PullMessages xmlns="http://www.onvif.org/ver10/events/wsdl">' +
'<Timeout>PT5S</Timeout>' + // pull timeout must be shorter than Socket timeout or we will get a socket error when there are no new events
'<Timeout>PT' + ((options.timeout || 5000) / 1000) + 'S</Timeout>' +
'<MessageLimit>' + (options.messageLimit || 10) + '</MessageLimit>' +
'</PullMessages>' +
this._envelopeFooter()
this._request({
url: urlAddress,
timeout: !isNaN(options.timeout) ? options.timeout + 5000 : 10000, // Socket timeout must be longer than pull timeout or we will get a socket error when there are no new events
body: sendXml
}, function(err, res, xml) {
if (!err) {
Expand Down Expand Up @@ -310,6 +311,7 @@ module.exports = function(Cam) {
if (this.listeners('event').length) { // check for event listeners, if zero, stop pulling
this.pullMessages({
messageLimit: this.events.messageLimit
, timeout: this.events.timeout
}, function(err, data, xml) {
if (!err) {
if (data.notificationMessage) {
Expand Down