Comments (5)
The example you are using is from older code.
The readme has updated example.
the login procedure is different, as well as the use of done handler:
var MikroNode = require('mikronode');
var device = new MikroNode('192.168.0.1');
device.connect()
.then(([login])=>{
return login('username','password');
})
.then(function(conn) {
chan.write('/ip/address/print');
chan.on('done',function(data) {
// data is all of the sentences in an array.
data.forEach(function(item) {
console.log('Interface/IP: '+item.data.interface+"/"+item.data.address);
});
chan.close(); // close the channel. It is not autoclosed by default.
conn.close(); // when closing connection, the socket is closed and program ends.
});
from mikronode.
I tried to use :
var device = new MikroNode('192.168.0.1');
device.connect()
.then(([login])=> {
return login('username','password');
})
.then(function(conn) {
chan.write('/ip/address/print');
chan.on('done',function(data) {
// data is all of the sentences in an array.
data.forEach(function(item) {
console.log('Interface/IP: '+item.data.interface+"/"+item.data.address);
});
chan.close(); // close the channel. It is not autoclosed by default.
conn.close(); // when closing connection, the socket is closed and program ends.
});
});
But still get the same error :
/Users/me/Desktop/mknode/node_modules/mikronode/dist/mikronode.js:474
_parsed$.set(this, _sentence$.get(this).do(function (d) {
^
TypeError: _sentence$.get(...).do is not a function
at new SocketStream (/Users/me/Desktop/mknode/node_modules/mikronode/dist/mikronode.js:474:52)
at MikroNode.connect (/Users/me/Desktop/mknode/node_modules/mikronode/dist/mikronode.js:330:30)
at Object.<anonymous> (/Users/me/Desktop/mknode/app.js:28:8)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
error Command failed with exit code 1.
Is there something wrong with my environment? i'm using Node.js v8.9.4
from mikronode.
Correct code for getting IP address. (Missed parsing the data)
device.connect()
.then(([login])=> {
return login('username','password');
})
.then(function(conn) {
console.log("Connected");
var chan=conn.openChannel();
chan.write('/ip/address/print');
chan.on('done',function(data) {
// data is full results (data.data), with metadata.
// Convert data from routeros data format to flat object results
const results = data.data.map(MikroNode.resultsToObj);
results.forEach(function(item) {
console.log('Interface/IP: '+item.interface+"/"+item.address);
});
chan.close(); // close the channel. It is not autoclosed by default.
conn.close(); // when closing connection, the socket is closed and program ends.
});
}).catch(error=>{
console.log("Caught error:",error);
});
```javascript
I ran your test, and did not have a problem.
I just noticed that you are installing rxjs v6, I make sure you only use 5 I have not updated to support the major breaking changes that v6 introduces.
from mikronode.
I tried to install v5 of rxjs and it works.
Thank you very much.
from mikronode.
No problem.
from mikronode.
Related Issues (20)
- read ECONNRESET error HOT 1
- peg$SyntaxError: Expected [\r\n\0] or [^\r\n\0] but end of input found. HOT 2
- Is maintaining?
- Change port HOT 1
- Mikronode has a problem connection
- I can't catch this anomaly
- Printing arp produces an error HOT 1
- Problem with log in HOT 1
- Way to retrieve connection quality and speed HOT 3
- mikronode needs rxjs 5.3.0 HOT 3
- Getting unexpected clean exit on login :( HOT 3
- "find" issue
- ERROR: Can't resolve 'dgram' in ...
- Mikronode won't connect if I pass a domain instead of an Ip Address
- _sentence$.get(...).do is not a function HOT 2
- Writing ip/hotspot/print results in SyntaxError: Expected [.a-z\-0-9] but "H" found HOT 2
- Why I'm getting this error?
- Connection problem with mikronode HOT 1
- Mikronode is listening to process events
- read ECONNRESET error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mikronode.