错误:在Node.js中使用basic-ftp时,服务器意外发送FIN数据包

6fe3ivhb  于 11个月前  发布在  Node.js
关注(0)|答案(1)|浏览(146)

我在Node.js中使用basic-ftp库连接到Pure-FTPd服务器时遇到问题。连接和文件列表工作正常,但当我尝试使用downloadTo下载文件时,我收到以下错误:

Error: Server sent FIN packet unexpectedly, closing connection.
    at Socket.<anonymous> (/home/schemannkurier/api/sk_backend/node_modules/basic-ftp/dist/FtpContext.js:129:56)
    at Socket.emit (node:events:526:35)
    at Socket.emit (node:domain:488:12)
    at endReadableNT (node:internal/streams/readable:1589:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

字符串

FTP会话

Connected to 192.168.179.71:21 (No encryption)
< 220---------- Welcome to Pure-FTPd [TLS] ----------
... (server welcome message)
> OPTS UTF8 ON
< 200 OK, UTF-8 enabled
... (login and feature negotiation)
> PASV
< 227 Entering Passive Mode (192,168,179,71,182,86)
> RETR /schemannkurier/Gutschein_Example.odt
< 150-Accepted data connection
150 63.4 kbytes to download
Downloading from 192.168.179.71:46678 (No encryption)
> QUIT
Error: Server sent FIN packet unexpectedly, closing connection.
... (more details in the error message)

验证码

const ftp = require("basic-ftp");
const FTPclient = new ftp.Client();

async function connectFTP() {
    try {
        FTPclient.ftp.verbose = true;
        await FTPclient.access({
            host: "192.168.179.71",
            user: "admin",
            password: "******", // (masked for security)
            port: 21,
            secure: false
        });
        console.log(await FTPclient.list());
        await FTPclient.downloadTo("/home/schemannkurier/Documents/skbackend/otheruploads/Gutschein_Example.odt", "/schemannkurier/Gutschein_Example.odt");
    } catch (err) {
        console.log(err);
    }
}

connectFTP();

**其他详细信息:**Node.js版本:20.10.0 FTP服务器:Pure-FTPd [TLS]使用basic-ftp库进行FTP交互。

我已经尝试过故障排除,但我无法查明“服务器意外发送FIN数据包”错误的原因。任何关于解决此问题的见解或建议都将不胜感激。谢谢!

monwx1rj

monwx1rj1#

您不必通过FTP在nodejs中连接到nas服务器,您也可以通过smb将nas服务器挂载到特定路径,然后您可以在挂载smb共享的路径上访问nas服务器的文件。

相关问题