Firstly, is there a reason you are not using node-red-node-snmp?
Secondly, as you are running async code, you cannot return msg
you need to use node.send
e.g....
// NPM module exposed as variable, npm_module
const session = snmp.createSession ("192.168.10.250", "public");
const oids = ["1.3.6.1.2.1.1.1.0"];
session.get (oids, function (error, varbinds) {
if (error) {
node.error(error, msg);
} else {
for (let i = 0; i < varbinds.length; i++) {
const e = snmp.varbindError(varbinds[i]);
if (e) {
node.error(e, msg);
} else {
msg.payload = varbinds[i].value;
msg.topic = varbinds[i].oid;
node.send(msg)
}
}
}
session.close ();
});
/// return msg; << delete this