Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use SNMPjs in react native #256

Open
PantTushar opened this issue Oct 24, 2017 · 1 comment
Open

use SNMPjs in react native #256

PantTushar opened this issue Oct 24, 2017 · 1 comment

Comments

@PantTushar
Copy link

This is not an issue but an ask, has anyone tried using the snmpjs in react native and render it for android or ios devices?. I tried it doing it but facing a issue - following is the code snippet

import snmp from 'net-snmp';
//====================================== net-snmp
const session = snmp.createSession('10.20.27.221', 'public', 161);

const oids = ['1.3.6.1.2.1.1.5.0', '1.3.6.1.2.1.1.6.0'];

 session.get(oids, (error, varbinds) => {
    if (error) {
        console.error(error);
    } else {
            console.log(varbinds[0].value);
      }
});
session.trap(snmp.TrapType.LinkDown, (error) => {
    if (error) {
        console.error(error);
    }
});

When I try to execute the above code i get the following error on android simulator
The

The development server returned response error code: 500

URL: http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false

Body:
{"from":"/Users/Documents/projects/auth/node_modules/net-snmp/index.js","to":"dgram","message":"Unable to resolve module dgram from /Users/Documents/projects/auth/node_modules/net-snmp/index.js: Module does not exist in the module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n 1. Clear watchman watches: watchman watch-del-all.\n 2. Delete the node_modules folder: rm -rf node_modules && npm install.\n 3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache.","name":"UnableToResolveError","type":"UnableToResolveError","errors":[{}]}
processBundleResult
BundleDownloader.java:225
access$100
BundleDownloader.java:40
onResponse
BundleDownloader.java:192
execute
RealCall.java:135
run
NamedRunnable.java:32
runWorker
ThreadPoolExecutor.java:1162
run
ThreadPoolExecutor.java:636
run
Thread.java:764

@chxmbley
Copy link

Late reply, but React Native does not have the same API as Node.js, and snmpjs relies on Node's dgram module since SNMP is built on top of UDP.

This library is a good drop-in replacement for Node's dgram module in React Native.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants