When using ftpClient.connect with an existing host that does not have ftp service, the timeout occurs only after 5 minutes, which is too much.
I tried to set various timeouts (setDefaultTimeout, setDataTimeout) that did not change anything.
FtpClient inherits from SocketClient , which has the setConnectTiemout method, but when I use it, I get java.lang.NoSuchMethodError: org/apache/commons/net/ftp/FTPClient.setConnectTimeout when it starts. This seems to be due to some J2SW 1.2 compatibility, as described in the Commons-net FAQ:
Q: How to set the connection timeout? http://wiki.apache.org/commons/Net/FrequentlyAskedQuestions
They propose to implement their own SocketFactory object to create objects from the extended Socket class using a specific timeout. However, when I try to use ftpClient.setSocketFactory I also get java.lang.NoSuchMethodError .
Any help how to reduce connection timeout?
source share