From 1dd749ca2530f8abc097c5a79ce733e6ec8a2b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sverre=20Johan=20T=C3=B8vik?= Date: Fri, 29 Jul 2022 15:33:34 +0200 Subject: [PATCH] Add session error handler in getSession --- gapit-snmp.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gapit-snmp.js b/gapit-snmp.js index be90c65..8f7e8ba 100644 --- a/gapit-snmp.js +++ b/gapit-snmp.js @@ -373,6 +373,11 @@ module.exports = function (RED) { sessions[sessionKey] = snmp.createSession(host, node.config.community, options); } + sessions[sessionKey].on("error", function (error) { + console.log ("Session error: " + error.toString()); + node.closeSession(); + }) + node.sessionKey = sessionKey; return sessions[sessionKey]; }