FTPSClient Problem to Upload a File - 425 Unable to build data connection

Viewed 353

I'm triying upload a file with FTPS with FTPSClient, but for any reason it's not working.

I'm doing the upload to the FPS Server as can see below:

FTPSClient client = null;
            logger.info("Enviando archivo por FTPS");
            client = new FTPSClient();
            client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
        
        try {
            client.setBufferSize(1024 * 1024); 
            client.connect(connection.getHOST(), connection.getPORT()); 
            client.connect("servidor.ftp.com");
            client.login(connection.getUSER(), connection.getPASSWORD());
            client.execPBSZ(0L);
            client.execPROT("P");
            //client.execCCC();
            client.pwd();
            client.enterLocalPassiveMode();  
            client.setFileType(FTP.BINARY_FILE_TYPE);
            client.changeWorkingDirectory(connection.getWORKINGDIR());
            for (String file : files) {
                f = new File(file);
                boolean uploadFile = client.storeFile(f.getName(), new FileInputStream(f));

                if (uploadFile == false) {
                    logger.error("File Upload Failed " + f.getName() + " by " + TYPEFTP);
                } else {
                    logger.info("File upload successfully" + f.getName() + " by" + TYPEFTP);
                }
            }
        } catch (Exception ex) {
            logger.error(ex);
        } finally {
            try {
                client.logout();
                client.disconnect();
            } catch (IOException ex) {
                logger.error(ex);
            }
         }

But when try:

client.storeFile(f.getName(), new FileInputStream(f))

I recibe the next response:

425 Unable to build data connection: TLS session of data connection not resumed.

Here is the output of the FTP Response: FTPS ERROR

I've tried follow some examples like: https://www.tabnine.com/code/java/methods/org.apache.commons.net.ftp.FTPSClient/login

But I'm not sure whats is wrong.

The conexion to the FTP is a FTP with TSL/SSL explicit encryption Thanks in advance for any help

0 Answers
Related