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

Getting unexpected clean exit on login :( #86

Open
hostmit opened this issue Apr 13, 2019 · 3 comments
Open

Getting unexpected clean exit on login :( #86

hostmit opened this issue Apr 13, 2019 · 3 comments

Comments

@hostmit
Copy link

hostmit commented Apr 13, 2019

Hello! I'm getting really strange behavior with mikronode login method.

On some devices I connect It does clean exit (I assume process.exit(0) somewhere in package) on connect() method.

Here is code I use

async function mtkApiValidate(host, user, pass) {
  let Device = new mikroNode(host, 8728, 3);
  let result = false;
  await Device.connect(user, pass)
  .then(([login]) => login(user, pass))
    .then(async function (conn) {
      result = true;
      await conn.close()
    })
    .catch(async function (err) {
      let msg;
      if (typeof (err) == 'string') {
        msg = err;
      } else {
        msg = JSON.stringify(err)
      }
      logger.error(`Unable to connect to ${host} => ${user}:${pass}, error was : ${msg}`);
    })
  return result;

Try this IP 94.230.155.137 with any login/pass. It wont get pass login() line, doesnt go into catch. Just clean exit???

Please help.

@xeleniumz
Copy link
Contributor

your code mixing between async await and promise. please recheck your code. this is example

    try {
                    let device = new MikroNode('192.168.1.1');
                    let conn = await device.connect()
                        .then(([login]) => {
                            return login('admin','123456');
                        });
                    conn.closeOnDone(true);

                    let c1 = conn.openChannel();
                    c1.closeOnDone(true);
 
                    let data = await c1.write(`/system/routerboard/print`);
                    let v = MikroNode.resultsToObj(data.data);
                    console.log(v);
                 
                } catch (error) {
                    console.log(error)
                }  

                    

@BurakOgutken
Copy link

BurakOgutken commented Jul 24, 2019

hello
when i try to connect router i am getting this error

 try {
                    let device = new MikroNode('192.168.1.1');
                    let conn = await device.connect()
                        .then(([login]) => {
                            return login('admin','123456');
                        });
                    conn.closeOnDone(true);
                    let c1 = conn.openChannel();
                    c1.closeOnDone(true);

                    let data = await c1.write(`/system/routerboard/print`);
                    let v = MikroNode.resultsToObj(data.data);
                    console.log(v);
                } catch (error) {
                    console.log(error)
                } 

ypeError: _sentence$.get(...).do is not a function at new SocketStream (C:\Workspaces\SysSoft AG\NodeJS\api.routerboard\node_modules\mikronode\dist\mikronode.js:474:52)
at MikroNode.connect (C:\Workspaces\SysSoft AG\NodeJS\api.routerboard\node_modules\mikronode\dist\mikronode.js:330:30)
at C:\Workspaces\SysSoft AG\NodeJS\api.routerboard\api.surflog.js:16:33
at Layer.handle [as handle_request] (C:\Workspaces\SysSoft AG\NodeJS\api.routerboard\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Workspaces\SysSoft AG\NodeJS\api.routerboard\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Workspaces\SysSoft AG\NodeJS\api.routerboard\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (C:\Workspaces\SysSoft AG\NodeJS\api.routerboard\node_modules\express\lib\router\layer.js:95:5)
at C:\Workspaces\SysSoft AG\NodeJS\api.routerboard\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Workspaces\SysSoft AG\NodeJS\api.routerboard\node_modules\express\lib\router\index.js:335:12)
at next (C:\Workspaces\SysSoft AG\NodeJS\api.routerboard\node_modules\express\lib\router\index.js:275:10)

@SOCK-RAW
Copy link

await need async

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

5 participants
@hostmit @xeleniumz @SOCK-RAW @BurakOgutken and others