commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julius Davies" <>
Subject RE: [commons-net ftp] why is commons ftp so slow compared with http?
Date Fri, 11 Aug 2006 05:06:08 GMT
Anil Philip,

Personally, I find FTPClient a lot snappier and more reliable if I go into passive mode:

FTPClient ftpClient = new FTPClient();
ftpClient.setDefaultTimeout( 60 * 1000 );
ftpClient.setSoTimeout( 60 * 1000 );
ftpClient.setDataTimeout( 60 * 1000 );

ftpClient.connect( "" );
ftpClient.login( "julius", "password" );

// Enter PASSIVE mode!


Julius Davies

-----Original Message-----
From:	Daniel F. Savarese []
Sent:	Thu 8/10/2006 7:48 PM
Subject:	Re: [commons-net ftp] why is commons ftp so slow compared with http? 

In message <>, Anil Philip wr
>My program is logging into my server and doing an ls
>in an almost empty directory. It takes about 10
>Contrast this with: I create an .htaccess file in the
>same dir so that the dir can be accessed in Internet
>Explorer and lists the folder contents. (Options
>+Indexes). It takes about 2.5 seconds.
>why is commons-net so painfully slow compared with
>http for a similar operation? (Is it just the

Presumably you're talking about FTP.  FTPClient is far from perfect
and its implementation is very dated and inefficient.  However, one
should always keep in mind that the basic code has been used by 
innumerable programmers for almost 10 years now, so when you run
into an issue like this, it's probably not commons-net, but rather
how you're using it.

First, establishing a new FTP connection every time you list a
directory will always be slower than HTTP.  First you have to log in,
then you have to establish a data connection for the file listing.
The fact that it takes 10 seconds for you has to do with your
particular code and runtime environment.  Using a modified version
of the example (so that it will print a listing in addition
to performing the file transfer), I can list
in less than a second.  And that includes the JVM start up time (I
just use /usr/bin/time to time it).

Without a precisely specified test case that other people can run to
try to reproduce the behavior you are encountering, there's no telling
what you are experiencing.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message