You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by bu...@apache.org on 2003/04/24 21:33:25 UTC

DO NOT REPLY [Bug 19286] New: - httpClient incorrectly closing tunnelled connection right after tunnell established

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19286>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19286

httpClient incorrectly closing tunnelled connection right after tunnell established

           Summary: httpClient incorrectly closing tunnelled connection
                    right after tunnell established
           Product: Commons
           Version: 2.0 Beta 1
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: HttpClient
        AssignedTo: commons-httpclient-dev@jakarta.apache.org
        ReportedBy: bin.chen@sabre-holdings.com


Description:

We are using httpClient to go through a proxy server using https protocol.  
After getting the 200 from proxy server ("CONENCT" request), the tunnelled 
connection is opened.  As httpClient is going to do the actual "POST", in 
checking the connection is open (inside HttpMethodBase.processRequest), the 
HttpConnection method is calling isStale ().  The isStale () method is trying 
to read 1 byte as means of verifying the connection is still open, when no 
bytes returned (byteRead = -1), it sets isStale to true and cause the 
connection to be closed.

The code fragment is:

                if (inputStream.available() == 0) {
                    LOG.debug ("inputStream.available() == 0");
                    try {
                        socket.setSoTimeout(1);
                        int byteRead = inputStream.read();
                        if (byteRead == -1) {
                            // again - if the socket is reporting all data read,
                            // probably stale
                            LOG.debug ("setting isStale to true due to byteRead 
= " + byteRead);
                            isStale = true;
                        } else {
                            inputStream.unread(byteRead);
                        }
                    } finally {
                        socket.setSoTimeout(soTimeout);
                    }
                }


The relavant trace/debug log is (I added some more logs):

2003/04/24 14:20:04:109 CDT [TRACE] HttpMethod - -enter 
HttpMethodBase.processRequest(HttpState, HttpConnection)
2003/04/24 14:20:04:109 CDT [TRACE] HttpMethod - -Attempt number 1 to process 
request
2003/04/24 14:20:04:109 CDT [DEBUG] HttpConnection - -inputStream.available() 
== 0
2003/04/24 14:20:04:109 CDT [DEBUG] HttpConnection - -setting isStale to true 
due to byteRead = -1
2003/04/24 14:20:04:109 CDT [DEBUG] HttpConnection - -Connection is stale, 
closing...
2003/04/24 14:20:04:109 CDT [TRACE] HttpConnection - -enter HttpConnection.close
()
2003/04/24 14:20:04:109 CDT [TRACE] HttpConnection - -enter 
HttpConnection.closeSockedAndStreams()