Hi!
We have to connect to a ftp server over ISDN. The ISDN connection is created on demand. If the ISDN connection is closed, creating a FTP connection would take around 40 seconds. Because of that we set the timeout to 2 minutes. In the example I created a small program which used a timeout of 60 seconds which was set as command line argument. Therefore the code example is just an example that you see how we set the timeout.
FTPClient ftp = new FTPClient();
ftp.setTimeout(60 * 1000);
But when we try to connect
ftp.connect();
we are getting a SocketTimeoutException after 20 seconds. I set the log level to debug. This are the logs:
INFO 2013-01-10 09:22:23,326 host: 192.168.0.13
INFO 2013-01-10 09:22:23,342 timeout in milliseconds: 60000
INFO 2013-01-10 09:22:23,342 user: test
DEBUG 2013-01-10 09:22:23,373 Class: com.enterprisedt.net.ftp.FTPClient
Location: file:/C:/Users/IRM/FtpConnectionTester_10.01.2012/FtpConnectionTester/lib/edtftpj-2.3.0.jar
Version: 2.3.0
Build timestamp: 26-Aug-2011 13:52:07 EST
Java version: 1.6.0_20
CLASSPATH: .;FtpConnectionTester.jar;lib\commons-cli-1.2.jar;lib\commons-logging-1.1.jar;lib\log4j-1.2.13.jar;lib\edtftpj-2.3.0.jar
OS name: Windows Server 2008 R2
OS arch: amd64
OS version: 6.1
INFO 2013-01-10 09:22:23,373 starting connect
DEBUG 2013-01-10 09:22:23,373 Connecting to /192.168.0.13:21
ERROR 2013-01-10 09:22:44,420 java.net.ConnectException: Connection timed out: connect
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.enterprisedt.util.proxy.PlainSocket.createPlainSocket(PlainSocket.java:122)
at com.enterprisedt.net.ftp.FTPControlSocket.<init>(FTPControlSocket.java:378)
at com.enterprisedt.net.ftp.FTPClient.connect(FTPClient.java:1003)
at at.irm.iopt.ftp.ConnectionTimeoutTest.run(ConnectionTimeoutTest.java:87)
at at.irm.iopt.ftp.ConnectionTimeoutTest.main(ConnectionTimeoutTest.java:104)
For sure, as a workaround I can create a loop around the connect statement and try to connect again, until 2 minutes are reached. But maybe you can solve it on your side, what I would like quit more.
Best regards
Markus