Javascript 使用“telnet客户端”时套接字不可写`
我使用下面的代码使用NodeJS执行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
套接字不可写
错误
'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
表示正在连接,然后会弹出一个空白屏幕,表示连接成功