Good afternoon,
I get a Read timed out Exception while trying to close the FileTransferInputStream. Downloading the data was successful.
The code is:
ftp = new FileTransferClient();
ftp.setRemoteHost(host);
ftp.setUserName(user);
ftp.setPassword(pw);
ftp.getAdvancedFTPSettings().setConnectMode(FTPConnectMode.PASV);
ftp.connect();
ftp.changeDirectory("incoming/test/");
File f = File.createTempFile("temp", ".pdf");
FileOutputStream fos = new FileOutputStream(f);
com.enterprisedt.util.debug.Logger.setLevel(com.enterprisedt.util.debug.Level.ALL);
StringBuffer s2 = new StringBuffer();
FileTransferInputStream in = ftp.downloadStream("1.pdf");
try {
int ch = 0;
while ((ch = in.read()) >= 0) {
s2.append((char)ch);
}
}
finally {
in.close(); // MUST be closed to complete the transfer
}
ftp.disconnect(true);
System.out.println("Example complete");
The exception:
com.enterprisedt.net.ftp.ControlChannelIOException: Read timed out
at com.enterprisedt.net.ftp.FTPControlSocket.readLine(FTPControlSocket.java:1029)
at com.enterprisedt.net.ftp.FTPControlSocket.readReply(FTPControlSocket.java:1064)
at com.enterprisedt.net.ftp.FTPClient.validateTransfer(FTPClient.java:2471)
at com.enterprisedt.net.ftp.FTPInputStream.close(FTPInputStream.java:358)
at date_small.Main$4.run(Main.java:281)
The Debuginformation:
DEBUG [FTPControlSocket] 12 Aug 2010 21:36:33.187 : ---> PASV
DEBUG [FTPControlSocket] 12 Aug 2010 21:36:33.203 : 227 Entering Passive Mode (127,0,0,1,234,101).
INFO [FTPControlSocket] 12 Aug 2010 21:36:33.203 : Substituting server supplied IP (127.0.0.1) with remote host IP (127.0.0.1)
DEBUG [FTPControlSocket] 12 Aug 2010 21:36:33.203 : ---> RETR 1.pdf
DEBUG [FTPControlSocket] 12 Aug 2010 21:36:33.203 : 150 Opening BINARY mode data connection for 1.pdf (25639 bytes)
DEBUG [FTPInputStream] 12 Aug 2010 21:36:33.218 : Transferred 25639 bytes from remote host
ERROR [FTPControlSocket] 12 Aug 2010 21:36:43.734 : Read failed ('' read so far)
I really have no idea why this Error is happening every time I want to download a File and i'm hoping for help.
Kind regards
Sebastian