Java ftps-无法获取数据连接
我正在尝试使用ssh/tls连接到ftp服务器,但我使用的每种方法都没有帮助Java ftps-无法获取数据连接,java,netbeans,Java,Netbeans,我正在尝试使用ssh/tls连接到ftp服务器,但我使用的每种方法都没有帮助 FTPSClient ftpsClient = new FTPSClient("TLS", false); // log.debug("using TLS"); FTPClientConfig ftpClientConfig = new FTPClientConfig(FTPClientConfig.SYST_UNIX); ftpClientConfig.setServerLanguage
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.
从我通过搜索web收集到的信息来看,这是因为ftp服务器希望客户端使用相同的会话来执行命令和数据传输 当前的解决方法是更改服务器配置,使其不强制会话重用。对于ProFtp,将在此链接中解释配置 不幸的是,我找不到哪里可以告诉他们的java客户机重用会话进行数据传输