0

I am using the following code to perform telnet using NodeJS but it is throwing socket not writable error

'use strict'

const Telnet = require('telnet-client')

async function run() {
  let connection = new Telnet()

  let params = {
    host: 'linux0203',
    port: 2345,
    shellPrompt: '/ # ',
    timeout: 1500
  }

  try {
    await connection.connect(params)
  } catch(error) {
    // handle the throw (timeout)
  }

  let res = await connection.exec('uptime')
  console.log('async result:', res)
}

run()

Error:

(node:23452) UnhandledPromiseRejectionWarning: Error: socket not writable
    at Promise (\home\user1\project\\node_modules\telnet-client\lib\index.js:147:23)
meallhour
  • 13,921
  • 21
  • 60
  • 117
  • To what kind of server do you want to connect to? Is it a telnet server or something else? Also please post: `telnet linux0203 2345` – raffis Oct 04 '19 at 07:05
  • As i mentioned in my question, telnet server is working. `telnet linux0203 2345` says connecting and then a blank screen pops up - which means connected successfuly – meallhour Oct 04 '19 at 15:12

0 Answers0