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:
und so bekomme ich eine Antwort:
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:
OUTPUT:
Hat jemand Paar Tips für mich was ich da falsch mache?
Danke schon mal!
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!