Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.8k views
in Java FTP by (120 points)
Im trying to set a timeout on an FTP Connect using com.enterprisedt.net.ftp.FTPClient but for some reason can't get it to work.

This is my code:

public boolean testFtpDetails(String path) {
    boolean success = false;
    try {
        FTPClient ftp = new FTPClient();
        ftp.setRemoteHost("210.160.1.100");
        ftp.setTimeout(3000);
        ftp.connect();

        ftp.login("test", "test");

        success = ftp.connected();

        if (success && path != null) {
            ftp.chdir(path);
        }

        ftp.quit();

    } catch (UnknownHostException e) {            
    } catch (IOException e) {            
    } catch (FTPException e) {
}


So after 3 seconds of trying to execute
ftp.connect()
I would expect it to timeout. However this does not happen and it takes around 15 seconds to timeout. Is there a way to change this?

Thanks,

1 Answer

0 votes
by (162k points)
Sorry for the delayed reply ... did you get anywhere with this? What version of Java?

Categories

...