We are trying to make use of the net-snmp node package in Meteor for talking to some physical devices and getting back information. We have tried following a number of examples but seem to have problems getting a return value from the call.
A simple portion of our code looks like the following inside Meteor.methods:
import snmp from 'net-snmp';
Meteor.methods({
snmpGet: function snmpGet(ip, oids, inCommunity) {
check(ip, String);
check(oids, [String]);
check(inCommunity, Match.Maybe(String));
const community = (typeof inCommunity === 'undefined') ?
Meteor.settings.private.snmp.public : inCommunity;
const session = snmp.createSession(ip, community);
const getResult = {};
const sessionGetSync = Meteor.wrapAsync(session.get);
try {
const result = sessionGetSync(oids);
getResult.success = true;
getResult.varbinds = result;
} catch (error) {
getResult.success = false;
getResult.error = error;
}
session.close();
return getResult;
},
});
Every time we call this it returns an error of âTypeError: this.simpleGet is not a functionâ and I am guessing it is because we use the snmp import to create the session, which in turn is what we are passing to the wrapAsync function. I have tried a number of variations to get this working, hoping somebody can provide me with the answer.
Thanks!