Closing a timed out socket takes the same amount of time as the connection took 
to time out, so the perceived timeout for an application thread is 2 x timeout.
---------------------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: HTTPCLIENT-1084
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1084
             Project: HttpComponents HttpClient
          Issue Type: Bug
    Affects Versions: 3.1 Final
            Reporter: Daniel Webster
            Priority: Minor


Closing a timed out socket takes the same amount of time as the connection took 
to time out, so the perceived timeout for an application thread is 2 x timeout.

For example, say you set the timeout value for a connection using

        HttpConnectionManager connectionManager = new 
MultiThreadedHttpConnectionManager();
        HttpConnectionManagerParams params = connectionManager.getParams();
        if(params == null){
            params = new HttpConnectionManagerParams();
        }
        
        params.setParameter(HttpConnectionManagerParams.SO_TIMEOUT, 
socketTimeout);
        params.setParameter(HttpConnectionManagerParams.CONNECTION_TIMEOUT, 
connectionTimeout);

        connectionManager.setParams(params);

        return connectionManager;

If the client attempts to open a connection to a server and requests data, and 
the server fails to respond for 10 seconds, the HttpClient will actually throw 
a timeout exception to code using HttpClient after 20 seconds (2x10). The call 
pattern seems to be 

after 10 seconds, a ConnectionTimeoutException is thrown inside 
org.apache.commons.httpclient.HttpConnection.open(). The open() method then 
catches that exception (line 748) and calls  closeSocketAndStreams() (on line 
751). The closeSocketAndStream() method then takes another "timeout" seconds. 
This time is consumed when closing the output stream (lines 1222-1231).

To fix this problem on our project, we switched the ordering of the socket 
shutdown and the stream shutdown (as shown in the attached patch). 



--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to