I am using the following code to ftp a file:
FileTransferClient ftp = null;
try {
ftp = new FileTransferClient();
ftp.setRemoteHost(custInfo.getFtpAddress());
if(custInfo.getPort() > 0)
ftp.setRemotePort(custInfo.getPort());
ftp.setUserName(custInfo.getFtpUser());
ftp.setPassword(custInfo.getFtpPassword());
log.info("Connecting to server " + custInfo.getFtpAddress());
ftp.connect();
log.info("Connected and logged in to server " + custInfo.getFtpAddress());
ftp.setContentType(FTPTransferType.BINARY);
if(custInfo.getFtpDirectory() != null)
ftp.changeDirectory(custInfo.getFtpDirectory());
ftp.uploadFile(file.getAbsolutePath(), file.getName());
} catch (Exception e) {
log.error("Transmission failed",e);
} finally {
try {
log.info("Quitting client");
if (ftp != null)
ftp.disconnect();
} catch (Exception e) {
log.error("Error in disconnecting ftp connection", e);
}
}
I got the "com.enterprisedt.net.ftp.ControlChannelIOException: Read timed out" Error. This issue is not consistent. The next time i ran this code, it works fine.
LOG:
Location: file:/home/usr/app/lib/edtftpj.jar
Version: 2.0.5
Build timestamp: 19-Oct-2009 13:44:01 EST
Java version: 1.5.0_17
CLASSPATH: app.jar
OS name: SunOS
OS arch: x86
OS version: 5.10
FileTransferClient - Configured client
FTPClient - Connecting to <SERVER_NAME>
FTPControlSocket - Read failed ('' read so far)
FTPControlSocket - Failed to initialize control socket
com.enterprisedt.net.ftp.ControlChannelIOException: Read timed out
at com.enterprisedt.net.ftp.FTPControlSocket.readLine(FTPControlSocket.java:1014)
at com.enterprisedt.net.ftp.FTPControlSocket.readReply(FTPControlSocket.java:1049)
at com.enterprisedt.net.ftp.FTPControlSocket.validateConnection(FTPControlSocket.java:418)
at com.enterprisedt.net.ftp.FTPControlSocket.<init>(FTPControlSocket.java:384)
at com.enterprisedt.net.ftp.FTPControlSocket.<init>(FTPControlSocket.java:355)
at com.enterprisedt.net.ftp.FTPClient.connect(FTPClient.java:958)
at com.enterprisedt.net.ftp.FileTransferClient.connect(FileTransferClient.java:383)
at FtpUtil.transferFile(Unknown Source)
at Main.execute(Unknown Source)
at Main.main(Unknown Source)
Is there any solution to this problem?
Thanks,
sassubra