superhero / js.telnet

Telnet module
MIT License
2 stars 3 forks source link

Cannot establish connection. Always getting timeout response. #1

Closed vksdgreat closed 6 years ago

vksdgreat commented 6 years ago

Hi i am trying to establish telnet connection with this module. but always get timeout in response. here is my code.

const telnet = require('@superhero/telnet')(
  {
    host : 'XXX.XXX.XXX.XXX',
    port : 23,
    timeout : 6000,
    onError : errCallback,
//    onEnd     : callback,
    onTimeout : timeoutCallback,
    debug : true
  }).connect();

  function errCallback(err) {
      console.log("Returned error : " + err);
  }

  function timeoutCallback(timeoutErr) {
      console.log("Timeout error : " + timeoutErr);
  }

  // all commands are stacked and performed in a series after each other.
  telnet
  .exec(/login: $/i, 'vinit')
  .exec(/password: $/i, 'vinit1234')

  /**
   * 1. regex, when found in returned string.. make new command
   * 2. the telnet command to perform
   * 3. callback with the returned data after the command has been performed
   */
  .exec(/# $/, 'ls', (data) => {
      console.log(data);
  });

How to resolve this issue or if there is some other error than how to get that error in response?

superhero commented 6 years ago

The example provided is specific to the server I ran it against, it may be different in your case. So you need to make sure that the regex matches the output from the sever you connect to.

Go to a console and use the telnet command and login, make a simple command and copy-paste the output of the whole process here, and I can have a better look.

superhero commented 6 years ago

I also updated the example in the readme file to reflect the current state of debugging. Please specify debug_level : 3 and paste the output from the console here as well.

superhero commented 6 years ago

Closing this as the TS did not follow up