Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.7k views
in Java FTP by (320 points)
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());
        }
    }

5 Answers

0 votes
by (162k points)
Firewall problem? Try active mode.
0 votes
by (320 points)
I've tried active mode already, still the same issues.... but thanks for your suggestion though :) It generates different error:

 ftp.setConnectMode(FTPConnectMode.ACTIVE);


DEBUG [FTPClient] 16 Jan 2012 14:09:47.564 : Connecting to ftp.sec.gov/162.138.185.33:21
DEBUG [FTPControlSocket] 16 Jan 2012 14:09:47.811 : 220 FTP server ready.
DEBUG [FTPControlSocket] 16 Jan 2012 14:09:47.812 : ---> USER anonymous
DEBUG [FTPControlSocket] 16 Jan 2012 14:09:47.938 : 331 Anonymous login ok, send your complete email address as your password
DEBUG [FTPControlSocket] 16 Jan 2012 14:09:47.939 : ---> PASS ********
DEBUG [FTPControlSocket] 16 Jan 2012 14:09:48.068 : 230-Please read the file README.txt
DEBUG [FTPControlSocket] 16 Jan 2012 14:09:48.069 :     it was last modified on Tue Aug 15 14:29:31 2000 - 4171 days ago
DEBUG [FTPControlSocket] 16 Jan 2012 14:09:48.069 : 230 Anonymous access granted, restrictions apply
DEBUG [FTPControlSocket] 16 Jan 2012 14:09:48.069 : ---> CWD edgar/daily-index/
DEBUG [FTPControlSocket] 16 Jan 2012 14:09:48.189 : 250 CWD command successful
DEBUG [FTPControlSocket] 16 Jan 2012 14:09:48.191 : ListenOnAllInterfaces=true
DEBUG [FTPControlSocket] 16 Jan 2012 14:09:48.193 : ---> PORT 192,168,1,10,201,143
ERROR [FTPControlSocket] 16 Jan 2012 14:09:48.193 : Read failed ('' read so far)
Caught exception: Software caused connection abort: recv failed
0 votes
by (320 points)
I finally know what the problem is. the software program Peerblock was blocking the traffic. Windows firewall is also blocking the traffic. I disabled Peerblock but i dont know why and how windows firewall is still blocking it.

Javaw.exe
java.exe
eclipse.exe are allowed already.. Please advice!
0 votes
by (162k points)
0 votes
by (320 points)
This solved the problem for me:

netsh advfirewall firewall add rule name=

Categories

...