AssertionError: 48 == 83
Closed this issue · 6 comments
Got the following error:
AssertionError: 48 == 83
at parse (/srv/httpd/dashboard/node_modules/snmp-native/lib/snmp.js:183:12)
at EventEmitter.msgReceived (/srv/httpd/dashboard/node_modules/snmp-native/lib/snmp.js:362:15)
at Socket.EventEmitter.emit (events.js:96:17)
at UDP.onMessage (dgram.js:350:8)
Message data:
53 70 6f 74 55 64 70 30 52 37 d8 75 89 71 3d 0e
00 01 00 04 48 95 c2 03 a2 b8 ae 7f d6 2e 5a b1
45 1e c7 7c e1 54 21 ec 55 61 18 a1
events.js:68
throw arguments[1]; // Unhandled 'error' event
^
AssertionError: 48 == 83
at parse (/srv/httpd/dashboard/node_modules/snmp-native/lib/snmp.js:183:12)
at EventEmitter.msgReceived (/srv/httpd/dashboard/node_modules/snmp-native/lib/snmp.js:362:15)
at Socket.EventEmitter.emit (events.js:96:17)
at UDP.onMessage (dgram.js:350:8)
Do you need some further information?
Hi!
Sorry for the long response time here, I missed the mail on this one. :( It seems that the data in question (that could not be parsed) is not a valid SNMP packet. Do you know what kind of device generated this and if possible in response to what command? Can you reproduce it?
Absolut no problem.
Unfortunately I'm not able to reproduce it. The error output was result of a long running monitoring script. The script watches multiple servers on multiple metrics and was not made to produce some more detailed error output.
So feel free to close the issue and I'll reopen it if the error occurs a second time.
Maybe the AssertionError could include some more details about the MIB and the host which was queried.
I can confirm this error is still happening on the latest version of the code, not sure if I should open a new ticket or continue this thread. I'm also attempting to consistently reproduce the problem.
So, this happens when the data that is parsed does not look like valid SNMP data. The behavior is intended, but the cause can be two things: the data is broken, in which case node-snmp is fine, or there is a bug/misunderstanding in the parser. Capturing the data, or pasting the output from node-snmp, can help clarify that.
To avoid crashing, you can listen for the error event on the session.
Can you show us the syntax to listen for error events? Do I just wrap the new session in a try catch or do I listen to for error events on the session socket?
try {
var session = new snmp.Session();
}catch(e){}
or
var session = new snmp.Session();
session.on("error", function(){});
Will that prevent the program from crashing if it receives bad input?
Thanks for your help
The latter should work.