I'm having difficulty using the commons.net.ftp.FTPClient when attempting to get a file list. The client connects correctly and I can issue CWD commands without difficulty, but as soon as I issue listFiles() or nlst() it fails with the reply string "Unable to build data connection: Connection timed out"
Does anyone have an idea of where I should start looking to fix this?
Thanks,
Kris Nuttycombe
Here is some debugging output:
0 [main] DEBUG gov.noaa.nosa.argo.ArgoReader - 220 zeus.aoml.noaa.gov FTP server ready
116 [main] DEBUG gov.noaa.nosa.argo.ArgoReader - 230 Anonymous access granted, restrictions apply.
167 [main] DEBUG gov.noaa.nosa.argo.ArgoReader - 250 CWD command successful.
170 [main] DEBUG gov.noaa.nosa.argo.ArgoReader - FTP connection successfully established to ftp.aoml.noaa.gov/phod/pub/ARGO_FTP/argo/nc/aoml
170 [main] DEBUG gov.noaa.nosa.argo.ArgoReader - FTP Data connection mode: 0
java.io.IOException: FTP client could not obtain file list : 425 Unable to build data connection: Connection timed out
Here is the code that generated it:
client.connect(host);
log.debug(client.getReplyString());
if(!FTPReply.isPositiveCompletion(client.getReplyCode())) {
throw new IOException("FTP server at host " + host + " refused connection.");
}
client.login(user, password);
log.debug(client.getReplyString());
if(!FTPReply.isPositiveCompletion(client.getReplyCode())) {
throw new IOException("FTP login failed for user anonymous: " + client.getReplyString());
}
client.changeWorkingDirectory(path);
log.debug(client.getReplyString());
if(!FTPReply.isPositiveCompletion(client.getReplyCode())) {
throw new IOException("FTP client could not change to remote directory " + path + ": " + client.getReplyString());
}
log.debug("FTP connection successfully established to " + host + path);
log.debug("FTP Data connection mode: " + client.getDataConnectionMode());
FTPFile[] files = client.listFiles(path);
if(!FTPReply.isPositiveCompletion(client.getReplyCode())) {
throw new IOException("FTP client could not obtain file list : " + client.getReplyString());
}
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]