문제

I am trying to make a ftp connection in Java with FTPClient.
I wanted to look what happens when i separate the line between Server and Client. My application freezed about 30seconds and then it thows a ConnectionException(Connection timed out). Thats why I searched for a timeout method for the FTPCliend and I found setDefaultTimeout() so I put the method before the connection attemp but it still freezed 30 sec...

    FTPClient ftp = new FTPClient();
    ftp.setDefaultTimeout(5000);
    ftp.connect(ip);

When i put "1.1.1.1" as ip the application throws fastly a ConnectionException(Connection refused) but when i put the right ipAdress its just freezing(30sec) and threwing the ConnectionException instead of the wished TimeoutException (after 5sec)

What am I doing wrong?

ps: excuse my horrible english knowledge ;)

도움이 되었습니까?

해결책

I'm not sure which FTPClient you're using because there are a couple out there. However, they usually have two different timeout options : one for data and one for actual connection. I suggest you search for a method called setConnectTimeout() or similar.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top