aluisiora / node-routeros Goto Github PK
View Code? Open in Web Editor NEWMikrotik Routerboard RouterOS API for NodeJS
License: MIT License
Mikrotik Routerboard RouterOS API for NodeJS
License: MIT License
const mikrotik = new rosapi({
host,
user,
password,
tls: true,
port: 8729
});
await mikrotik.connect();
console.log('connected');
await mikrotik.close();
console.log('closed... never gets here');
Without TLS it works as expected.
Occasionally, the api assign the wrong stack of data of the tag sentences received, making the index of the response being assign to 1, while the index 0 being a wrong sentence that should be part of the last packet processed.
This problem breaks when trying to print data, but it doesn't manifest very often.
I can not send this command /ppp secret print count-only where name =" username "
I use:
conn.write("/ppp/secret/print",[ "=count-only where name=username" ....
Could you help me?
Many thanks
Howdy! We are using the newest release of this library. It seems like we are hitting some stream parsing issue. We were using the Mikronode library previously and we needed to fix a bug regarding the sentance length parsing and I wonder if this is somehow related?
violetatrium/mikronode@10467e3
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type object
at Function.from (buffer.js:305:9)
at Receiver.processRawData (/usr/src/app/node_modules/node-routeros/dist/connector/Receiver.js:136:65)
at Connector.onData (/usr/src/app/node_modules/node-routeros/dist/connector/Connector.js:192:23)
at Socket.emit (events.js:223:5)
at Socket.EventEmitter.emit (domain.js:475:20)
at Shim.applySegment (/usr/src/app/node_modules/newrelic/lib/shim/shim.js:1424:20)
at Socket.wrapper [as emit] (/usr/src/app/node_modules/newrelic/lib/shim/shim.js:2065:17)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at Socket.Readable.push (_stream_readable.js:224:10)
/tool user-manager user create-and-activate-profile test profile=Basic customer=ADMIN
Tried this code and says cannot login.
const RosApi = require('node-routeros').RouterOSAPI;
const conn = new RosApi({
host: '*******',
user: '******',
password: '******',
});
conn
.connect()
.then(() => {
// Connection successful
console.log('Connection Successful')
})
.catch((err) => {
// Got an error while trying to connect
console.log(err);
});
Error
RosException: Username or password is invalid
at E:\Projects\mikrotek-test\node_modules\node-routeros\dist\RouterOSAPI.js:397:23
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
name: 'RosException',
errno: 'CANTLOGIN',
message: 'Username or password is invalid'
}
Hi,
Could you please look into this @aluisiora
Error: RosException: Timed out after 10 seconds
at RosException (..../node_modules/node-routeros/dist/RosException.js:11:14)
at onTimeout (..../node_modules/node-routeros/dist/connector/Connector.js:180:33)
at onceWrapper (events.js:277:12)
at emit (events.js:189:12)
at EventEmitter.emit (domain.js:459:22)
at Socket._onTimeout (net.js:440:7)
at ontimeout (timers.js:436:10)
at tryOnTimeout (timers.js:300:4)
at listOnTimeout (timers.js:263:4)
at processTimers (timers.js:223:9)
Hello. Thanks for the useful Library. How can I get Log Records by Topic Name, like by this RouterOS Command: log print where topics~"warning"
?
Of course, I can fetch all Records and then filter by JS Array Methods, but how can I it rich with Command Parameters?
v6.43 now has a new login method
Hi! I can delete anything.
I got empty array []
as response for deleting actions without any error
Hi
Been using the stream function to get tx and rx speeds of interfaces however seems like the packets i get back from the stream is not in JSON or OBJECT type what would be the best way to parse this so i can use it in my program
what i get back is below and for some odd reason when i try and parse it i get a error
might be me being dumb but assistance would be much appreciated
happy to share rest of my code if needed but is just a simple stream function :-)
tried running both
JSON.parse(packet);
JSON.parse(...packet);
error i get is
SyntaxError: Unexpected token o in JSON at position 1
[
{
name: 'wlan1',
'rx-packets-per-second': '3',
'rx-bits-per-second': '2016',
'fp-rx-packets-per-second': '3',
'fp-rx-bits-per-second': '2016',
'rx-drops-per-second': '0',
'rx-errors-per-second': '0',
'tx-packets-per-second': '5',
'tx-bits-per-second': '8880',
'fp-tx-packets-per-second': '3',
'fp-tx-bits-per-second': '3144',
'tx-drops-per-second': '0',
'tx-queue-drops-per-second': '0',
'tx-errors-per-second': '0',
'.section': '0'
}
]
[
{
name: 'wlan1',
'rx-packets-per-second': '4',
'rx-bits-per-second': '2752',
'fp-rx-packets-per-second': '4',
'fp-rx-bits-per-second': '2752',
'rx-drops-per-second': '0',
'rx-errors-per-second': '0',
'tx-packets-per-second': '6',
'tx-bits-per-second': '10016',
'fp-tx-packets-per-second': '3',
'fp-tx-bits-per-second': '3184',
'tx-drops-per-second': '0',
'tx-queue-drops-per-second': '0',
'tx-errors-per-second': '0',
'.section': '1'
}
]
Hard to reproduce.
Sometimes, when dealing with huge amount of received data, a UNKNOWNREPLY is thrown.
Still investigating.
During torch interval, if there is nothing to be displayed, nothing is received from the tcp socket. This might end in a timeout if keepalive is set to false.
I tested on my Mikrotik (just connecting):
{
name: "RosException",
errno: "SOCKTMOUT",
message: "Timed out after 10 seconds"
}
I applied to port 8728 but still, it doesn't work.
We have a few bad actors in our fleet of routers. We get periodic TCP connection resets from them which cause the connection to throw an error. When this happens any inflight API calls get orphaned - never to resolve or reject. Goofy example is as follows.
routeros.on('error', (e) => logger(e));
function doThings() {
let res = await routeros.write('/systen/resource/print');
console.log(res.data);
setTimeout(doThings, 5000);
}
doThings();
doThings
gets called/system/resource/print
gets sent to routerdoThings
gets called/system/resource/print
gets sent to router/system/resource/print
and we never proceedActual scenario is a bit more complex than this.... but I think this outlines the issue. Currently we have a workaround. But my suggestion would be for all inflight writes
to reject their promises upon connection error.
node-routeros does not provide TypeScript's d.ts files starting with version 1.4.4.
I tried installing them from the package @types/node-routeros
, but that doesn't exist.
Where may I find the TypeScript's d.ts files now?
How to detect when a RouterOSAPI.stream is complete?
I'm testing using the /ip/address/print command.
I was expecting the stream returned from RouterOSAPI.stream to emit either the close or the end event, but neither one is emitted.
conn.write("/ip/address/print", "=.id=*20").
its gives unknown parameter error
Currently, connecting with SSL via api is not very well tested, need to write tests and make fixes if needed.
Hello I have a problem with adding a queue.
If I add a queue record that already has a name, mikrotik rejects this request, of course.
The problem is that my node-routeros server crashes with the following error.
"failure: already have such name"
name: 'RosException',
errno: 'SOCKTMOUT',
message: 'Timed out after 10 seconds'
Is it possible to just get the error message and the server doesn't shut down?
I am currently writing a Telegram bot that can do the ping command (among other things) and I would like to hear if anyone can help with an example. So basically if ping count is not specified, make it 4 and ping to host at IP xxxx. If it possible to perhaps save the data after the run into min, average and max.
Thank you for the help
conn.write("/interface/bridge/vlan/print/terse")
[admin@MikroTik] interface pppoe-server> remove [find user=ex]
const response = await conn.write(["/interface/pppoe-server/remove", "?[find user=ex]"]);
No error happens, and the return is an empty array!
Help me please?
Hello.
Is there somewhere in the public access info how to prepare configs for multiple connections(lists with hosts, passwords, etc.)?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.