Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用“telnet客户端”时套接字不可写`_Javascript_Node.js_Node Modules_Telnet - Fatal编程技术网

Javascript 使用“telnet客户端”时套接字不可写`

Javascript 使用“telnet客户端”时套接字不可写`,javascript,node.js,node-modules,telnet,Javascript,Node.js,Node Modules,Telnet,我使用下面的代码使用NodeJS执行telnet,但它抛出了套接字不可写错误 'use strict' const Telnet = require('telnet-client') async function run() { let connection = new Telnet() let params = { host: 'linux0203', port: 2345, shellPrompt: '/ # ', timeout: 1500

我使用下面的代码使用NodeJS执行telnet,但它抛出了
套接字不可写
错误

'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()
错误:

(node:23452) UnhandledPromiseRejectionWarning: Error: socket not writable
    at Promise (\home\user1\project\\node_modules\telnet-client\lib\index.js:147:23)

要连接到哪种类型的服务器?它是telnet服务器还是其他什么?另外请发布:
telnet linux0203 2345
正如我在问题中提到的,telnet服务器正在工作
telnet linux0203 2345
表示正在连接,然后会弹出一个空白屏幕,表示连接成功