Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.4k views
in Java FTP by (200 points)
I have an application which FTP's a small file to multiple IP's when it runs into locations that it can't connect to it should just kick out stating that it couldn't connect (which it did most of the time). Now when I go to run the program it will run though the list of IP's and hang about half way though. It will hang on the connect, login or chdir commands (it will vary time to time). It doesn't seem to want to timeout or throw an exception. I want it to just skip the IP if is having poblems connecting to it and let me know by timing out or throwing an exception.

Any Ideas?

Here is the code I have:


public class FtpProc {
public FtpProc() {
}

public String FtpRun(String loc, String userid, String pwd, String FileNm) {

String Error;

FTPClient ftp = null;

try {
// set up client
ftp = new FTPClient();
ftp.setRemoteHost(loc);
FTPMessageCollector listener = new FTPMessageCollector();
ftp.setMessageListener(listener);

// connect
ftp.connect();
ftp.login(userid, pwd);
ftp.chdir("//loc/path");
ftp.put(FileNm, FileNm);
ftp.quit();

}
catch (Exception e) {
Error = " - Exception message: " + e.getMessage();
return Error;
}
return "";

}
}

4 Answers

0 votes
by (162k points)
Set the timeout.

I want it to just skip the IP if is having poblems connecting to it and let me know by timing out or throwing an exception.
0 votes
by (200 points)
Thanks didn't see the functions.

One last question.

What is a good timeout to set? I have it at 1000 milliseconds. Is that to small?
0 votes
by (162k points)
Try at least 5,000 ms.

Thanks didn't see the functions.

One last question.

What is a good timeout to set? I have it at 1000 milliseconds. Is that to small?
0 votes
by (200 points)
Thanks will do.

Categories

...