Read Time Out when using FTPClient in Java. Right at the end of the transfer

0

I hope you can help me.

I am trying to save a file on an FTP server that I have in WIndows Server 2012 with the following code, in fact I worked without problems when I had the FTP server in Linux.

FTPClient ftpClient = new FTPClient();
ftpClient.connect(InetAddress.getByName(argsFtp[ftpHost]), 21);
ftpClient.login(argsFtp[ftpUsuario], argsFtp[ftpClave]);

//Verificar conexión con el servidor.
String[] replies = ftpClient.getReplyStrings();
if (replies != null && replies.length > 0) {
    for (String aReply : replies) {
        System.out.println("SERVER: " + aReply);
    }
}

int reply = ftpClient.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
    System.out.println("Imposible conectarse al servidor FTP");
}

//Verificar si se cambia de direcotirio de trabajo
ftpClient.changeWorkingDirectory(argsFtp[rutaBackupFtp]);//Cambiar directorio de trabajo
//System.out.println("Se cambió satisfactoriamente el directorio: " + ftpClient.printWorkingDirectory());

//Activar que se envie cualquier tipo de archivo
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
//ftpClient.setKeepAlive(true); 
//ftpClient.setControlKeepAliveTimeout(180); // set timeout to 3 minutes
//ftpClient.setControlKeepAliveReplyTimeout(3000); 
// data transfer timeout
//ftpClient.setDataTimeout(30000);
//ftpClient.setSoTimeout(30000);
//ftpClient.setBufferSize(1024*1024);
ftpClient.setCopyStreamListener(createListener());
FileInputStream buffIn = new FileInputStream(argsFtp[rutaBackupLocal]);//Ruta del archivo para enviar
ftpClient.enterLocalPassiveMode();
ftpClient.storeFile(argsFtp[nombreBackUp], buffIn);//Ruta completa de alojamiento en el FTP

buffIn.close(); //Cerrar envio de archivos al FTP
ftpClient.logout(); //Cerrar sesión
ftpClient.disconnect();//Desconectarse del servidor
System.out.println("Enviado Backup al servidor por FTP...OK");

During the process I check on the server and the file is loading, when it is finished, it shows me the following error and the file is deleted.

  

java.net.SocketTimeoutException: Read timed out at   java.net.SocketInputStream.socketRead0 (Native Method) at   java.net.SocketInputStream.socketRead (SocketInputStream.java:116) at   java.net.SocketInputStream.read (SocketInputStream.java:171) at   java.net.SocketInputStream.read (SocketInputStream.java:141) at   sun.nio.cs.StreamDecoder.readBytes (StreamDecoder.java:284) at   sun.nio.cs.StreamDecoder.implRead (StreamDecoder.java:326) at   sun.nio.cs.StreamDecoder.read (StreamDecoder.java:178) at   java.io.InputStreamReader.read (InputStreamReader.java:184) at   java.io.BufferedReader.fill (BufferedReader.java:161) at   java.io.BufferedReader.read (BufferedReader.java:182) at   org.apache.commons.net.io.CRLFLineReader.readLine (CRLFLineReader.java:58)   at org.apache.commons.net.ftp.FTP .__ getReply (FTP.java:321) at   org.apache.commons.net.ftp.FTP .__ getReply (FTP.java:300) at   org.apache.commons.net.ftp.FTP.getReply (FTP.java:732) at   org.apache.commons.net.ftp.FTPClient.completePendingCommand (FTPClient.java:1853)   at org.apache.commons.net.ftp.FTPClient._storeFile (FTPClient.java:694)   at   org.apache.commons.net.ftp.FTPClient .__ storeFile (FTPClient.java:639)   at org.apache.commons.net.ftp.FTPClient.storeFile (FTPClient.java:2030)   at eidybackup.EidyBackup.enviarBackupFTP (EidyBackup.java:338) at   eidybackup.EidyBackup.main (EidyBackup.java:172)

Thank you.

    
asked by Xanders 20.12.2018 в 19:30
source

0 answers