When using ftpClient.connect
with an existing host who has no ftp service active, timeout occurs only after 5 minutes, which is much too long.
I tried setting diverse timeouts (setDefaultTimeout, setDataTimeout) which did not change anything.
FtpClient
inherits from SocketClient
which has a setConnectTimeout method, but when I use this I get a java.lang.NoSuchMethodError: org/apache/commons/net/ftp/FTPClient.setConnectTimeout
when running it. This seems to be because of some J2SW 1.2 compatibility, as described in Commons-net FAQ:
Q: How can I set a connection timeout? http://wiki.apache.org/commons/Net/FrequentlyAskedQuestions
They suggest to implement an own SocketFactory
creating objects from an extended Socket class using a specific timeout. However, when trying to use ftpClient.setSocketFactory
I also get a java.lang.NoSuchMethodError
.
Any help how I can reduce the connect timeout?