node-telnet-client icon indicating copy to clipboard operation
node-telnet-client copied to clipboard

Telnet connection breaks a process

Open barwalker opened this issue 2 years ago • 1 comments

Hi, I try to send a connecting request to an IP and it refuses with this message: in terminal:

$ telnet 10.123.9.236 2361
Trying 10.123.9.236...
Connected to 10.123.9.236.
Escape character is '^]'.
*** Maximum number of clients reached.
  * Please, try again later.
  * Exiting...
Connection closed by foreign host.

That issue interrupts the code below:

let connection = new Telnet();
 let params = {
     host: '10.123.9.236',
     port: 2361,
     negotiationMandatory: false,
     shellPrompt: '/ # ',
     ors: '\r\n', // mandatory for your 'send' to work
     timeout: 1000,
     sendTimeout: 2000,
     maxBufferLength: '5M'
 };

 try {
     await connection.connect(params);
     console.log(ip, 222);
     let xxx = await connection.send('act-user::abcdef::Wsn7;', {waitfor: ';\r\n>'});
     console.log(ip, 333, xxx);
 } catch (error) {
     console.log(ip, 'error::', error.toString());
 }

Output:

$ node test.js
10.123.9.236 222
$

It breaks the whole process, it should raise an error and runs into a catch block. Please help me handle this problem.

barwalker avatar May 31 '22 09:05 barwalker