1

我一直在寻找答案,但我发现的最接近的事情就是责怪服务器。

这是我的代码,对于我的应用程序,我正在使用 Zehon 库:

import com.zehon.BatchTransferProgressDefault;
import com.zehon.FileTransferStatus;
import com.zehon.exception.FileTransferException;
import com.zehon.ftps.FTPsClient;

public class UploadFolderSample {
/**
 * Please refer to http://www.zehon.com/FTPs_samples.htm for its full source code
 * @param args
 */
public static void main(String[] args) {
    String host = "****";
    int port = 990;
    String username = "******";
    String password = "*******";
    String sendingFolder = "*******/";
    String destFolder = "ftpes:******/";

    try {
        com.zehon.ftps.FTPsClient ftps = new FTPsClient(host, port, username, password, false);
        ftps.folderExists(destFolder);
        int status  = ftps.sendFolder(sendingFolder, destFolder, new BatchTransferProgressDefault());

        if(FileTransferStatus.SUCCESS == status){
            System.out.println(sendingFolder + " got ftps-ed successfully to  folder "+destFolder);
        }
        else if(FileTransferStatus.FAILURE == status){
            System.out.println("Fail to ftps  to  folder "+destFolder);
        }
    } catch (FileTransferException e) {
        e.printStackTrace();
    }       
}

}

这是我的错误:

Thank you for using Zehon software (www.zehon.com).  
Please go to http://www.zehon.com/feedback.php to provide us your feedback about the product.
Please go to http://www.zehon.com/feature_request.php to submit bugs or feature requests.
com.zehon.exception.FileTransferException: org.apache.commons.net.ftp.FTPConnectionClosedException: Connection closed without indication.
    at com.zehon.ftps.FTPsClient.folderExists(FTPsClient.java:1239)
    at test.UploadFolderSample.main(UploadFolderSample.java:34)
Caused by: org.apache.commons.net.ftp.FTPConnectionClosedException: Connection closed without indication.
    at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:313)
    at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:290)
    at org.apache.commons.net.ftp.FTP._connectAction_(FTP.java:396)
    at org.apache.commons.net.ftp.FTPClient._connectAction_(FTPClient.java:796)
    at org.apache.commons.net.ftp.FTPSClient._connectAction_(FTPSClient.java:203)
    at org.apache.commons.net.SocketClient.connect(SocketClient.java:172)
    at org.apache.commons.net.SocketClient.connect(SocketClient.java:192)
    at com.zehon.ftps.FTPsClient.getFTPSClient(FTPsClient.java:1444)
    at com.zehon.ftps.FTPsClient.folderExists(FTPsClient.java:1236)
    ... 1 more

我真的需要一些帮助,我已经被 FTPS 困了一个多星期了。

编辑(添加对话框):当我使用错误的端口时会发生这种情况,但至少它以这种方式显示对话框。

> Thank you for using Zehon software (www.zehon.com).   Please go to
> http://www.zehon.com/feedback.php to provide us your feedback about
> the product. Please go to http://www.zehon.com/feature_request.php to
> submit bugs or feature requests. 220-FileZilla Server version 0.9.33
> beta 220 Welcome by ***** AUTH TLS 234 Using authentication type TLS
> USER ***** 331 Password required for ***** PASS ******* 230 Logged on
> SYST 215 UNIX emulated by FileZilla PASV 227 Entering Passive Mode
> (******) LIST ftpes:*****/ 550 PROT P required 220-FileZilla Server
> version 0.9.33 beta 220 Welcome by **** AUTH TLS 234 Using
> authentication type TLS USER **** 331 Password required for **** PASS
> **** 230 Logged on Transfer start for file ****\test.txt MODE S 200 MODE set to S. TYPE I 200 Type set to I PASV 227 Entering Passive Mode
> (*****) STOR ftpes:*****/test.txt 550 PROT P required Transfer error
> *****/test.txt Transfer complete for file *****/test.txt Transfer start for file *****/test.txt MODE S
4

1 回答 1

2

存在显式和隐式 FTPS (FTP-over-SSL)。在第一种情况下(通常)建立到端口 21 的连接,然后发送命令以通过已建立的通道协商 SSL。隐式 SSL 意味着通过端口(通常)990 进行连接,然后协商 SSL,然后通过 SSL 安全通道发送常规命令(LOGIN 等)。

如果混合使用两种模式(以非安全模式连接到端口 990 或尝试连接到端口 21 并立即启动 SSL 握手),则不会有任何效果。

所以首先要做的是找出你需要使用什么模式。然后设置正确的端口并检查您的库是否支持所需的模式。

于 2013-01-22T13:45:59.593 回答