commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 35777] - [net] FTPClient.connect() does not timeout
Date Tue, 19 Jul 2005 08:46:08 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35777>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35777


sms@pccl.demon.co.uk changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|LATER                       |




------- Additional Comments From sms@pccl.demon.co.uk  2005-07-19 10:46 -------
(In reply to comment #3)
> (In reply to comment #1)
> > Looking through the (1.4.0) code, I can't see setSoTimeout() being called 
on 
> > the control connection, only on the data connections. Could this be the 
cause 
> > of the problem?
> setSoTimeout affects only I/O operations on an established connection.  It
> doesn't affect connection establishment.  You can work around the issue with
> the SocketFactory as described in Comment #2, but the ultimate solution for
> this and other issues is to implement a Commons Net 2.0 that abandons
> compatibility with legacy Java releases and perhaps even abandons
> compatibility with Commons Net 1.x.

The problem is <b>not</b> to do with timing out the attempt to connect the 
socket. It is to do with timing out the initial FTP control dialogue after 
connecting at TCP level.

I have solved the problem by calling setDefaultTimeout() before connecting. 
This sets a timeout on receiving the first FTP message from the server. 

This use of setDefaultTimeout does not agree with the Javadoc, which reads:

setDefaultTimeout

Set the default timeout in milliseconds to use when opening a socket. This 
value is only used previous to a call to connect() and should not be confused 
with setSoTimeout() which operates on an the currently opened socket. 
_timeout_ contains the new timeout value. 


The timeout value is not used when connecting a socket but it is being used to 
timeout messages on the control connection. This is what I want. I call 
setDefaultTimeout(30 * 1000) before calling connect() then:

         1. If the server does not respond (by using a non-existent IP address)
            then connect() timesout after 3mins 45secs.
         2. If the server accepts the connection but does not send messages
            (using SimpleServer) then connect timesout after 30secs.
            
This leads us to another problem. When connect() fails in this way, the socket 
connection is still open and still connected to the server. This is solved by 
calling disconnect() even if connect() failed.

Summary
=======
To summarise, we have two problems. 

Firstly, the JavaDoc description of setDefaultTimeout() is wrong. Although 
setDefaultTimeout() does what I want it to do.

Secondly, When connect() establishes a TCP connection but subsequently fails, 
it does not close the socket.

I have now worked around these problems and have the software working again. I 
have reopened the bug to make sure that you see my response, you can reset it 
to "RESOLVED LATER" if you like.

Many Thanks

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message