Phi*_*p M 3 javascript ssh sftp node.js ssh2-sftp-client
我使用 ssh2-sftp-client 来获取一些文件。如果我使用 sftp.end(); 最后我在控制台中收到此错误:
{ Error: fastGet->exists->exists: No SFTP connection available
at Object.formatError (/home/project/node_modules/ssh2-sftp-client/src/utils.js:62:18)
at SftpClient.fastGet (/home/project/node_modules/ssh2-sftp-client/src/index.js:590:19)
at process._tickCallback (internal/process/next_tick.js:68:7) code: 'ERR_NOT_CONNECTED', custom: true } 'Error'
...
Run Code Online (Sandbox Code Playgroud)
我缺少什么?
我相信目前正在发生的事情是,由于您没有Promise从第二个返回 a then(),所以第三个then()会立即解决(值为undefined),这会导致您的连接立即终止(在您的fastGet()s 有时间完成之前)。
要解决此问题,您需要Promise从第二个显式返回一个then()只有在所有文件都已传输后才能解决的问题。如果至少其中一项转账失败,您可能还需要考虑拒绝该承诺。
| 归档时间: |
|
| 查看次数: |
5325 次 |
| 最近记录: |