You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2026/03/13 12:48:00 UTC
[jira] [Comment Edited] (NET-733) Java FTPs client lib connects to the server successfully but the list of directories is empty with an error with FileZilla servers
[ https://issues.apache.org/jira/browse/NET-733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18065636#comment-18065636 ]
Gary D. Gregory edited comment on NET-733 at 3/13/26 12:47 PM:
---------------------------------------------------------------
Hello [~mabouzeid]
Please try git master or a {{3.13.0-SNAPSHOT}} build from [https://repository.apache.org/content/repositories/snapshots/]
I reimplemented {{Util.copyStream()}} with IOUtils.copyLarge() and updated {{Util.DEFAULT_COPY_BUFFER_SIZE}} from 1 KiB to 8 KiB.
Otherwise, we'd need a unit test that reproduces the issue without going to the internet. Using Docker would be OK, or a local Java FTP server, as some tests already use ({{org.apache.ftpserver:ftpserver-core}}).
was (Author: garydgregory):
Hello [~mabouzeid]
Please try git master or a {{3.13.0-SNAPSHOT}} build from [https://repository.apache.org/content/repositories/snapshots/]
I reimplemented {{Util.copyStream()}} with IOUtils.copyLarge() and updated {{Util.DEFAULT_COPY_BUFFER_SIZE}} from 1 KiB to 8 KiB.
Otherwise, we'd need a unit test that reproduces the issue without going to the internet. Using Docker would be OK, or a local Java FTP server, like some of the tests already use.
> Java FTPs client lib connects to the server successfully but the list of directories is empty with an error with FileZilla servers
> ----------------------------------------------------------------------------------------------------------------------------------
>
> Key: NET-733
> URL: https://issues.apache.org/jira/browse/NET-733
> Project: Commons Net
> Issue Type: Bug
> Components: FTP
> Affects Versions: 3.9.0, 3.11.1
> Reporter: Mohammed Abouzeid
> Priority: Critical
> Fix For: 3.13.0
>
>
> I'm using java commons-net client lib to connect to FTPs servers, I can connect with servers successfully. Still, when calling "ftps.listDirectories()" I get "0" when connecting with FileZilla servers with errors:
> * Error while transferring data: PROT C is not allowed when the control connection is secure. Use PROT P. -> If didn't use ftps.execPROT("P");
> * Error while transferring data: TLS session of data connection not resumed. -> If did use ftps.execPROT("P");
> This issue doesn't occur with all FTPs servers.
> I have tried to create FTPs server locally but I have noticed the following while trying to connect:
> * FileZilla server's old version (v0.9.60.0) can connect and can "ftps.listDirectories()" if "force PROT to encrypt file transfares when using FTP over TLS" is unchecked.
> * FileZilla server's new version (v1.8.2.0) only connects but can't "getListDirectories()", always empty with the errors I mentioned above.
> Please note I have tried the FileZilla client version (v3.67.1) to make sure I can connect to FTPs servers and explore files/directories without any problems.
> // To Connect with FTP/s Servers (but no issue with connection at all)
> {code:java}
> public FTPConnection(String host, String username, String password, boolean passive) throws IOException {
> if (ftps) {
> this.log = Logger.getLogger(host);
> this.host = host;
> this.clientFtps = new FTPSClient(false);
> try {
> this.clientFtps.connect(host);
> } catch (Exception e) {
> log.debug(e.getStackTrace());
> }
> if (username != null)
> try {
> if (pasv) {
> this.clientFtps.enterLocalPassiveMode();
> } else {
> this.clientFtps.enterLocalActiveMode();
> }
> this.clientFtps.login(username, password);
> //log.debug(this.clientFtps.getReplyString());
> } catch (IOException ex) {
> ex.printStackTrace();
> }
> this.clientFtps.setFileType(FTP.BINARY_FILE_TYPE);
> this.clientFtps.setFileTransferMode(FTP.BINARY_FILE_TYPE);
> log.debug("the type of ftp file is : " + FTP.BINARY_FILE_TYPE);
> } else {
> this.host = host;
> this.log = Logger.getLogger("ftp://" + host);
> log.debug("ftp://" + host);
> this.client = new FTPClient();
> this.client.connect(host);
> if (username != null)
> try {
> this.client.login(username, password);
> log.debug(this.client.getReplyString());
> } catch (IOException ex) {
> ex.printStackTrace();
> }
> this.client.setFileType(FTP.BINARY_FILE_TYPE);
> this.client.setFileTransferMode(FTP.BINARY_FILE_TYPE);
> log.debug("the type of ftp file is : " + FTP.BINARY_FILE_TYPE);
> if (pasv)
> this.client.enterLocalPassiveMode();
> else
> this.client.enterLocalActiveMode();
> }
> } {code}
> // To explore files/directories (here's the problem)
> {code:java}
> public String[] dirs() throws IOException {
> if (ftps) {
> FTPFile[] files = clientFtps.listDirectories();
> if (files == null)
> return new String[0];
> String[] result = new String[files.length];
> for (int i = 0; i < result.length; i++)
> result[i] = files[i].getName();
> return result;
> } else {
> FTPFile[] files = client.listDirectories();
> if (files == null)
> return new String[0];
> String[] result = new String[files.length];
> for (int i = 0; i < result.length; i++)
> result[i] = files[i].getName();
> return result;
> }
> } {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)