PhysX
15-08-2012, 16:26
Ho scritto questo semplice codice di prova che deve solo elencare i file su un server FTP:
import it.sauronsoftware.ftp4j.*;
public class FTPtest {
public static void main(String[] args) throws Exception {
FTPClient client = new FTPClient();
client.connect("ftp.it.debian.org");
client.login("anonymous", "");
client.changeDirectory("/debian/pool/main");
String dir = client.currentDirectory();
System.out.println("Directory corrente: " + dir);
FTPFile[] list = client.list();
for (FTPFile l: list) {
System.out.println(l.getName());
}
client.disconnect(true);
}
}
Il problema è che con qualunque server FTP lo provo mi da sempre l'errore Exception in thread "main" java.net.SocketException: Connection reset:
Exception in thread "main" java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at sun.nio.cs.StreamDecoder.read0(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at it.sauronsoftware.ftp4j.NVTASCIIReader.readLine(NVTASCIIReader.java:105)
at it.sauronsoftware.ftp4j.FTPCommunicationChannel.read(FTPCommunicationChannel.java:142)
at it.sauronsoftware.ftp4j.FTPCommunicationChannel.readFTPReply(FTPCommunicationChannel.java:187)
at it.sauronsoftware.ftp4j.FTPClient.openPassiveDataTransferChannel(FTPClient.java:3614)
at it.sauronsoftware.ftp4j.FTPClient.openDataTransferChannel(FTPClient.java:3549)
at it.sauronsoftware.ftp4j.FTPClient.list(FTPClient.java:2078)
at it.sauronsoftware.ftp4j.FTPClient.list(FTPClient.java:2273)
at FTPtest.main(FTPtest.java:20)
Ho guardato i sorgenti di ftp4j e fino a quel punto mi sembra tutto liscio, mi sa che è un problema a basso livello del protocollo FTP, magari c'è qualche parametro da settare... avete qualche idea?
import it.sauronsoftware.ftp4j.*;
public class FTPtest {
public static void main(String[] args) throws Exception {
FTPClient client = new FTPClient();
client.connect("ftp.it.debian.org");
client.login("anonymous", "");
client.changeDirectory("/debian/pool/main");
String dir = client.currentDirectory();
System.out.println("Directory corrente: " + dir);
FTPFile[] list = client.list();
for (FTPFile l: list) {
System.out.println(l.getName());
}
client.disconnect(true);
}
}
Il problema è che con qualunque server FTP lo provo mi da sempre l'errore Exception in thread "main" java.net.SocketException: Connection reset:
Exception in thread "main" java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at sun.nio.cs.StreamDecoder.read0(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at it.sauronsoftware.ftp4j.NVTASCIIReader.readLine(NVTASCIIReader.java:105)
at it.sauronsoftware.ftp4j.FTPCommunicationChannel.read(FTPCommunicationChannel.java:142)
at it.sauronsoftware.ftp4j.FTPCommunicationChannel.readFTPReply(FTPCommunicationChannel.java:187)
at it.sauronsoftware.ftp4j.FTPClient.openPassiveDataTransferChannel(FTPClient.java:3614)
at it.sauronsoftware.ftp4j.FTPClient.openDataTransferChannel(FTPClient.java:3549)
at it.sauronsoftware.ftp4j.FTPClient.list(FTPClient.java:2078)
at it.sauronsoftware.ftp4j.FTPClient.list(FTPClient.java:2273)
at FTPtest.main(FTPtest.java:20)
Ho guardato i sorgenti di ftp4j e fino a quel punto mi sembra tutto liscio, mi sa che è un problema a basso livello del protocollo FTP, magari c'è qualche parametro da settare... avete qualche idea?