Closed RogerHardiman closed 3 years ago
I think best to add to the README and let the user decide if they want to ignore the error. There could be cases where a legitimate error is thrown and someone would want to catch that (ie a camera with new firmware responding with different XML)
Just my 2c
I agree. Thanks Chris
Have added Error handler and updated Documentation.
For reference if there is no 'error' handler, you get
events.js:305
throw err; // Unhandled 'error' event
^
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('Wrong SOAP message from 192.168.1.236:60188')
at EventEmitter.emit (events.js:303:17)
at /mnt/c/Users/roger/source/onvif/lib/discovery.js:108:15
at parseSOAPString (/mnt/c/Users/roger/source/onvif/lib/utils.js:108:3)
at Socket.listener (/mnt/c/Users/roger/source/onvif/lib/discovery.js:99:3)
at Socket.emit (events.js:314:20)
at UDP.onMessage [as onmessage] (dgram.js:921:8) {
code: 'ERR_UNHANDLED_ERROR',
context: 'Wrong SOAP message from 192.168.1.236:60188'
}
Hi Had an install where an unknown make of NAS drive responded to the ONVIF Discovery probe. This library realised it could not process the XML reply and tried to emit the Discovery 'error' event. However the example code and the README don't mention adding a on('error') handler for discovery.
I am not 100% we even want to tell the user of the library that discovery had a problem, but maybe the places where it emits an 'error' event for Discovery should check for any subscribers before they emit the 'error' event.
I can probably pick this up myself in the future but wanted to record the Issue now so I don't forget it.