ftps-无法获得数据连接

时间:2014-03-10 17:31:11

标签: java netbeans

我正在尝试使用ssh / tls连接到ftp服务器,但我使用的每种方法都没有帮助。

    FTPSClient ftpsClient = new FTPSClient("TLS", false);
   // log.debug("using TLS");
    FTPClientConfig ftpClientConfig = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
    ftpClientConfig.setServerLanguageCode("de");
    ftpsClient.configure(ftpClientConfig);
    ftpsClient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); // outputs all conversation to the console
    ftpsClient.connect(domain, 21);
    // Set protection buffer size
    ftpsClient.execPBSZ(0);
    // Set data channel protection to private
    ftpsClient.execPROT("P");
    ftpsClient.login(username, password);
    ftpsClient.enterLocalPassiveMode();
    ftpsClient.changeWorkingDirectory(filepath);
    ftpsClient.execPBSZ(0);
    // Set data channel protection to private
    ftpsClient.execPROT("P");
    ftpsClient.listFiles();
    ftpsClient.logout();

但我一直得到同样的错误 -

250 CWD command successful
PBSZ 0
200 PBSZ 0 successful
PROT P
200 Protection set to Private
PASV
227 Entering Passive Mode (188,65,181,123,23,20).
LIST
150 Opening ASCII mode data connection for file list
425 Unable to build data connection: Operation not permitted
TLS
QUIT
221 Goodbye.

1 个答案:

答案 0 :(得分:2)

通过搜索网络收集的内容,这是由于ftp服务器希望客户端使用相同的会话进行命令和数据传输。

当前的解决方法是更改​​服务器配置,以便它不会强制执行会话重用。对于ProFtp,配置将在此链接http://www.proftpd.org/docs/howto/TLS.html上进行说明。

不幸的是,我无法找到可以告诉他们的Java客户端重用会话进行数据传输的地方。