Socket not writable while using `telnet-client`

廉价感情. 提交于 2019-12-11 14:31:54

问题


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)

来源:https://stackoverflow.com/questions/58212553/socket-not-writable-while-using-telnet-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!