Hi all, Im experiencing some problems with the FTP from SEC (Public FTP server for public). Connecting to the FTP is successful, however whatever i do after the connection results in error "ERROR [FTPControlSocket] Read failed ('' read so far)". Please see an example of the error below. Please advice, what am i doing wrong?.
Since it is a public government FTP, everyone is allowed to connect using username:
"anonymous" with your own email address as password. Please feel free to try connecting your self and see if you have the same problems
DEBUG [FTPClient] 16 Jan 2012 13:16:46.293 : Connecting to ftp.sec.gov/162.138.185.33:21
DEBUG [FTPControlSocket] 16 Jan 2012 13:16:46.547 : 220 FTP server ready.
DEBUG [FTPControlSocket] 16 Jan 2012 13:16:46.548 : ---> USER anonymous
DEBUG [FTPControlSocket] 16 Jan 2012 13:16:46.669 : 331 Anonymous login ok, send your complete email address as your password
DEBUG [FTPControlSocket] 16 Jan 2012 13:16:46.670 : ---> PASS ********
DEBUG [FTPControlSocket] 16 Jan 2012 13:16:46.790 : 230-Please read the file README.txt
DEBUG [FTPControlSocket] 16 Jan 2012 13:16:46.791 : it was last modified on Tue Aug 15 14:29:31 2000 - 4171 days ago
DEBUG [FTPControlSocket] 16 Jan 2012 13:16:46.791 : 230 Anonymous access granted, restrictions apply
DEBUG [FTPControlSocket] 16 Jan 2012 13:16:46.791 : ---> CWD edgar
DEBUG [FTPControlSocket] 16 Jan 2012 13:16:46.912 : 250-CWD command successful
DEBUG [FTPControlSocket] 16 Jan 2012 13:16:46.915 : Please read the file README.txt
DEBUG [FTPControlSocket] 16 Jan 2012 13:16:46.915 : 250 it was last modified on Tue Jul 10 10:40:51 2007 - 1652 days ago
DEBUG [FTPControlSocket] 16 Jan 2012 13:16:46.915 : ---> PASV
ERROR [FTPControlSocket] 16 Jan 2012 13:16:47.035 : Read failed ('' read so far)
Caught exception: Connection reset
The code i used:
private static void newTestEnterpriseFTP(){
String host = "ftp.sec.gov";
String user = "anonymous";
String password = "password";
String filename = "README.txt";
String directory = "edgar";
Logger.setLevel(Level.ALL);
try {
FTPClient ftp = new FTPClient();
ftp.setControlEncoding("UTF-8");
ftp.setRemoteHost(host);
ftp.connect();
ftp.login(user, password);
ftp.chdir("edgar");
ftp.dir();
}
catch (Exception ex) {
System.out.println("Caught exception: " + ex.getMessage());
}
}