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

Help set up the connection

Open MGMehdi opened this issue 9 months ago • 0 comments

Hello,

I try to set up the package for a simple connection without login. I've try some example but it seem that the connection doesn't work. The code have to work on Windows and the connection is working using the telnet client feature.

Here is the code

import { Telnet } from "telnet-client";
const connection = new Telnet();

// these parameters are just examples and most probably won't work for your use-case.
const params = {
  host: "192.168.10.112",
  port: 4567,
  negotiationMandatory: false,
};

connection.on("ready", (prompt) => {
  console.log("prompt", prompt);

  connection.exec(cmd, (err, response) => {
    console.log("rep", response);
  });
});

connection.on("timeout", () => {
  console.log("socket timeout!");
  connection.end();
});

connection.on("close", () => {
  console.log("connection closed");
});

connection.connect(params);

And here is the result

socket timeout!
connection closed

Thanks

MGMehdi avatar May 17 '24 10:05 MGMehdi