【问题标题】:FluentFTP EPSV Error 425 Can't open data connection for transfer of "/test.csv"FluentFTP EPSV 错误 425 无法打开数据连接以传输“/test.csv”
【发布时间】:2021-09-06 12:37:30
【问题描述】:

我正在尝试使用 EPSV 连接类型通过 .NET 库 FluentFTP 上传文件,因为我使用的是 HTTP/1.1 代理,并且数据和控制 FTP IP 地址不同。

不幸的是,我在调用 UploadFile 方法时收到以下错误: 响应:425 Can't open data connection for transfer of "/test.csv"

相同的操作在具有相同代理设置的 FileZilla 客户端中有效,因此不会是网络问题。 这是我的代码:

using (FtpClientProxy client = new FtpClientHttp11Proxy(new ProxyInfo() {
    Host = "prox.corp.company.com",
    Port = 80,
    Credentials = new NetworkCredential("proxyuser", "password")})) {
        client.Host = "1.123.123.123";
        client.Port = 990;
        client.Credentials = new NetworkCredential("ftpuser", "password");
        client.SslProtocols = System.Security.Authentication.SslProtocols.Tls12;
        client.DataConnectionType = FtpDataConnectionType.EPSV;
        client.EncryptionMode = FtpEncryptionMode.Implicit;
        client.Connect();

        client.UploadFile(@"C:\test.csv", "/test.csv");
}

FluentFTP 日志文件和 FileZilla Client 日志文件的比较显示相同的操作。

FluentFTP 日志:

Command:  SIZE /test.csv
Response: 550 File not found

OpenWrite("/test.csv", Binary)
Command:  TYPE I
Response: 200 Type set to I

OpenPassiveDataStream(EPSV, "STOR /test.csv", 0)
Command:  EPSV
Response: 229 Entering Extended Passive Mode (|||40160|)
Status:   Connecting to 1.123.1.123:80 // HTTP-Proxy
HTTP/1.1 200 Connection established

Command:  STOR /test.csv
Response: 425 Can't open data connection for transfer of "/test.csv"
Status:   Disposing FtpSocketStream...

FileZilla 客户端日志:

Status: Starting upload of C:\test.csv
Command: CWD /
Response: 250 CWD successful. "/" is current directory.
Command: TYPE I
Response: 200 Type set to I
Command: EPSV
Response: 229 Entering Extended Passive Mode (|||40132|)
Command: STOR test.csv
Status: Connection with proxy established, performing handshake...
Response: Proxy reply: HTTP/1.1 200 Connection established
Response: 150 Opening data channel for file upload to server of "/test.csv"
Response: 226 Successfully transferred "/test.csv"
Status: File transfer successful, transferred 24 bytes in 1 second

【问题讨论】:

    标签: c# ftp fluentftp


    【解决方案1】:

    我遇到了同样的问题,并设法使用这些设置上传了文件:

    ftpClient.SslProtocols = SslProtocols.None | SslProtocols.Tls12;
    ftpClient.ValidateAnyCertificate = true;
    ftpClient.DataConnectionEncryption = false;
    

    我认为这里的关键是 DataConnectionEncryption。

    【讨论】:

    • 好的,但这三个设置都会降低安全性。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-31
    • 2014-06-01
    相关资源
    最近更新 更多