You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mike Mercier <mm...@gmail.com> on 2005/04/22 16:18:24 UTC

Timeout problem with FTPClient

Hi,

I am using FTPClient to connect to a remote FTP Server that seems to
be unreliable.

I have a class (FTPClientControl) that does all the necessary
initializations and has the following procedure:

   public boolean fetchFileNamed(FtpFileTableObject fileName,
FileOutputStream outStream) {
        try {
            ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
            // fileName.getFullPath() would be for ex: /home/user/subdir/myfile
            ftpClient.retrieveFile(fileName.getFullPath(), outStream);
            outStream.close();
        } catch (Exception e) {
            System.out.println(e.getLocalizedMessage());
            return false;
        }
        return true;
    }

I call the procedure by looping over a predermined list of files that
I know exist on the FTP server.  What happens, is that the app will
freeze trying to download files on occasion.  I have tried a linux
command line client as well as ws-ftp to the same server and have had
the same problems.  I though I had resolved the issue by doing a
logout and login if the above procedure returned false, but it seems
that the procedure sometimes never returns.

Is there a way to setup a timeout on the FTPClient.retrieveFile call
so that I can continue normally?

Thanks,
Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org