Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.6k views
in Java FTP by (200 points)
Please help on what could be wrong - get errors when running following a simple test:
FileTransferClient ftp = null;
try {
ftp = new FileTransferClient();

// set remote host
ftp.setRemoteHost("ftp.company.com");
ftp.setUserName("user");
ftp.setPassword("pwd");

ftp.connect();
ftp.setContentType(com.enterprisedt.net.ftp.FTPTransferType.BINARY);
ftp.getAdvancedFTPSettings().setConnectMode(
com.enterprisedt.net.ftp.FTPConnectMode.PASV);

com.enterprisedt.util.debug.Logger.setLevel(com.enterprisedt.util.debug.Level.DEBUG);

ftp.changeDirectory("DevRemote");
com.enterprisedt.net.ftp.FTPFile files[] = ftp.directoryList(".");
for (com.enterprisedt.net.ftp.FTPFile file : files) {
if (file.isFile()) {
System.out.println(file.getName() + "||" + file.lastModified());
InputStream in = ftp.downloadStream(file.getName());
System.out.println(in.available());
}

}
ftp.disconnect();

} catch (Exception e) {
e.printStackTrace();
}


The log details:
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.711 : ---> CWD DevRemote
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.711 : 250 Directory successfully changed.
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.711 : ---> SYST
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.711 : 215 XXXXXXXXXXXXX
WARN [FTPFileFactory] 12 Nov 2010 11:22:01.711 : Unknown SYST 'XXXXXXXXXXXXX' - defaulting to Unix parsing
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.711 : ---> PWD
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.711 : 257 "/DevRemote"
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.711 : ---> PASV
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.711 : 227 Entering Passive Mode (192,168,0,21,65,167)
INFO [FTPControlSocket] 12 Nov 2010 11:22:01.711 : Substituting server supplied IP (192.168.0.21) with remote host IP (192.168.0.21)
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.726 : ---> LIST .
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.726 : 150 Here comes the directory listing.
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.726 : 226 Directory send OK.
DEBUG [FTPFileFactory] 12 Nov 2010 11:22:01.726 : Confirmed format UNIX
DE_lang_glossary.xls||Wed Sep 22 15:24:00 EDT 2010
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.726 : ---> PASV
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.726 : 227 Entering Passive Mode (192,168,0,21,24,242)
INFO [FTPControlSocket] 12 Nov 2010 11:22:01.726 : Substituting server supplied IP (192.168.0.21) with remote host IP (192.168.0.21)
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.726 : ---> RETR DE_lang_glossary.xls
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.726 : 150 Opening BINARY mode data connection for DE_lang_glossary.xls (5542400 bytes).
0
ES_lang_glossary.xls||Wed Sep 22 15:24:00 EDT 2010
DEBUG [FTPControlSocket] 12 Nov 2010 11:22:01.726 : ---> PASV
ERROR [FTPControlSocket] 12 Nov 2010 11:22:20.617 : Read failed ('' read so far)
ERROR [FTPClient] 12 Nov 2010 11:22:20.617 : Caught and rethrowing exception in initGet() : Connection reset
com.enterprisedt.net.ftp.ControlChannelIOException: Connection reset
at com.enterprisedt.net.ftp.FTPControlSocket.A(Unknown Source)
at com.enterprisedt.net.ftp.FTPControlSocket.E(Unknown Source)
at com.enterprisedt.net.ftp.FTPControlSocket.sendCommand(Unknown Source)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocketPASV(Unknown Source)
at com.enterprisedt.net.ftp.FTPControlSocket.A(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.setupDataSocket(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.initGet(Unknown Source)
at com.enterprisedt.net.ftp.FTPInputStream.<init>(Unknown Source)
at com.enterprisedt.net.ftp.FileTransferClient.downloadStream(Unknown Source)

1 Answer

0 votes
by (156k points)
You have to close the input stream. Also, you don't seem to be reading it ...

Categories

...