Skip to content

Commit

Permalink
Merge pull request #2 from leo-combes/proposed-solution-to-#70
Browse files Browse the repository at this point in the history
proposed solution to calmh#70
  • Loading branch information
leo-combes authored Jun 2, 2018
2 parents 72ad8db + f5072a3 commit 47e129a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/snmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,17 +411,18 @@ function msgReceived(msg, rinfo) {
pkt = parse(msg);
} catch (error) {
// cancel completely this request
// console.warn('Error while parsing response, maybe a malformed package has been received...');
console.warn('Error while parsing response, maybe a malformed package has been received...');

console.error('Message that caused the error:');
// an error while parsing response, maybe a malformed package has been received...
var hex = msg.toString('hex');
var description = "problem parsing snmp response, malformed packet?";
while (hex.length > 0) {
console.error(' ' + hex.slice(0, 32).replace(/([0-9a-f]{2})/g, '$1 '));
description = description+'\n'+hex.slice(0, 32).replace(/([0-9a-f]{2})/g, '$1 ');
hex = hex.slice(32);
}

var response = self.reqs[Object.keys(self.reqs)[0]].callback(new Error("problem parsing response, malformed packet?"));
var error = new Error(description);
error.name = "Error decoding response";
var response = self.reqs[Object.keys(self.reqs)[0]].callback(error);

clearRequest(self.reqs, Object.keys(self.reqs)[0]);
return response;
}
Expand Down

0 comments on commit 47e129a

Please sign in to comment.