FTP Befehl 'LIST' | Read timed out

Dit_

Bekanntes Mitglied
Hallo,

folgendes Problem.

Ich muss ein FTP Modul schreiben. Funktionert bis jetzt fast alles einwandfrei, download, upload, verzeichniswechsel, passiveMod usw. Will ich aber den Inhalt eines Verzeichnisses auflisten bekomme ich Read timed out (IOException).

Timeout ist auf 300 ms eingestellt, habe versucht mehr Zeit zu geben (über 2 Min.), hat nicht geholfen.

So sende ich Befehle:
Java:
 private void sendCommand(String command) throws BadFTPConnectionException, FTPException {
        // SENDE BEFEHL
        try {
            if (connected) {
                if (DEBUG) {
                    System.out.println("User: " + command);
                }
                writer.write(command);
                writer.write("\r\n");
                writer.flush();
            } else {
                throw new BadFTPConnectionException("You are not connected!");
            }
        } catch (IOException e) {
            throw new FTPException(e.getMessage());
        }
        getReplyCode();
    }


und so bekomme ich eine Antwort:
Java:
private void loadServerReply() throws BadFTPConnectionException {
        String t = "";
        int timeout = 0;
        do {
            try {
//            	if(reader.ready())
                t = reader.readLine();
            } catch (IOException e) {
                if (timeout++ == 10) {
                    throw new BadFTPConnectionException(e.getMessage());
                } else {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e1) {
                        //
                    }
                }
            }
            if (DEBUG && t.length() > 0) {
                System.out.println("FTP-Server: " + t);
            }
        } while (!isLastLine(t));
        
        reply = t;
    }

wenn ich Zeile 6 "aktiviere", dann gibt es kein Exception, programm bleibt an dieser Stelle hängen, so als ob der Server noch etwas von mir möchte...


Main Methode:
Java:
 FTP f = new FTP(accessData);
        try {
            f.connect();
            f.login();
            f.enterPassiveMode();
            f.setFileType(FileTypes.ASCII_TYPE);
            f.noop();
            f.getCurrentDirectory();
            f.fileList();
            
        } catch (FTPErrorException e) {
            e.printStackTrace();
        } finally {
            f.disconnect();
        }

OUTPUT:
FTP-Server: 220 FTP Server ready.
User: USER dit
FTP-Server: 331 Password required for dit
User: PASS k5ffj3dfjda5u3f
FTP-Server: 230 User dit logged in.
User: pasv
FTP-Server: 227 Entering Passive Mode (74,139,191,12,187,31).
User: type a
FTP-Server: 200 Type set to A
User: NOOP
FTP-Server: 200 NOOP command successful
User: PWD
FTP-Server: 257 "/" is the current directory
User: LIST

exceptions.ftp.BadFTPConnectionException: Read timed out
User: quit
at modules.ftp.FTP.loadServerReply(FTP.java:596)
at modules.ftp.FTP.getReplyCode(FTP.java:568)
at modules.ftp.FTP.sendCommand(FTP.java:557)
at modules.ftp.FTP.fileList(FTP.java:900)
at modules.ftp.FTP.main(FTP.java:922)
exceptions.ftp.BadFTPConnectionException: Read timed out
at modules.ftp.FTP.loadServerReply(FTP.java:596)
at modules.ftp.FTP.getReplyCode(FTP.java:568)
at modules.ftp.FTP.sendCommand(FTP.java:557)
at modules.ftp.FTP.logout(FTP.java:523)
at modules.ftp.FTP.disconnect(FTP.java:496)
at modules.ftp.FTP.main(FTP.java:927)

Hat jemand Paar Tips für mich was ich da falsch mache?

Danke schon mal!
 

HoaX

Top Contributor
Na du schreibst doch quasi schon die Lösung. Er wartet auf irgendwas ... schau doch mal ins RFC 959 was da zu LIST steht ;)
 

Dit_

Bekanntes Mitglied
This command causes a list to be sent from the server to the
passive DTP. If the pathname specifies a directory or other
group of files, the server should transfer a list of files
in the specified directory. If the pathname specifies a
file then the server should send current information on the
file. A null argument implies the user's current working or
default directory. The data transfer is over the data
connection in type ASCII or type EBCDIC. (The user must
ensure that the TYPE is appropriately ASCII or EBCDIC).
Since the information on a file may vary widely from system
to system, this information may be hard to use automatically
in a program, but may be quite useful to a human user.
:shock:

sorry vielleicht bin ich einfach blind... In php ging der Befehl zumindest ohne zusatz strings... ;(
 

Ähnliche Java Themen

Neue Themen


Oben