Mohammed Abouzeid created NET-733:
-------------------------------------

             Summary: 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.11.1, 3.9.0
            Reporter: Mohammed Abouzeid
             Fix For: 3.11.2


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)

Reply via email to