简体   繁体   中英

ftps- unable to get data connection

i am trying to connect to an ftp server using ssh/tls but every method i have used hasn't been helpful.

    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();

but i keep getting the same error-

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.

From what I have gathered through searching the web, this is caused by the ftp server wanting the client to use the same session for both commands and data transfer.

The current work around is to change the server config so that it doesn't enforce session reuse.For ProFtp the config are explained on this link http://www.proftpd.org/docs/howto/TLS.html .

Unfortunately I could not find where one can tell their java client to reuse the session for data transfer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM