javascript - sftpConnect:远程主机已重置连接:在使用 ssh2-sftp-client 时在节点 js 中读取 ECONNRESET
问题描述
我试图列出目录中的所有文件,即远程路径。我能够使用它。现在我在使用“listAllFiles”时收到以下错误。
const Client = require("ssh2-sftp-client");
const conn= new Client();
const listAllFiles = () => {
return new Promise(function (resolve, reject) {
try {
conn
.connect(config)
.then(() => {
console.log("Connected to server .......")
return conn.list(remotePath);
})
.then((data) => {
console.log('Listing directory.........')
// console.log(data);
filesInDir = data;
resolve(filesInDir);
})
.then(() => {
setTimeout(() => {
conn.end();
}, 60000);
})
.catch((err) => {
console.log("error --------------", err.message)
reject(err.message);
});
} catch (error) {
reject(error);
}
});
};
为什么我会得到这个。
RuntimeError: abort(sftpConnect: Remote host has reset the connection: read ECONNRESET). Build with -s ASSERTIONS=1 for more info.
解决方案
推荐阅读
- iphone - 如何在 Xcode 11.3.1 中测试 3.5 屏幕尺寸的布局,特别是 iPhone 4s?
- javascript - 设置最后做某事的倒计时
- javascript - 通过 JavaScript 限制单选按钮的选择
- node.js - 如何以 JSON 形式返回 mongoose 集合项?
- java - 为什么 Minecraft 的 setLightLevel 无法正常工作?
- unit-testing - t.Cleanup 有什么用处?
- c# - 从 ms 访问保存/加载/编辑 TreeView
- node.js - 如何在聊天机器人和 Web 应用程序之间传输消息?
- swift - 无法将函数的变量分配给 Swift 上的标签
- php - 谷歌照片参考图片下载上传到S3