You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by paul <tj...@fairex.com> on 2004/05/27 12:54:36 UTC

HttpClient problems

Dear all,

  Need help on using Httpclient 2.0. Currently, I have encountering a 
random problem with sending xml over to a remote site. Here's the debug 
log :

===================================================
2004/05/26 20:09:50:290 SGT [DEBUG] EntityEnclosingMethod - -Request 
body sent
2004/05/26 20:09:50:562 SGT [DEBUG] HttpMethodBase - -Closing the 
connection.
2004/05/26 20:09:50:563 SGT [INFO] HttpMethodBase - -Recoverable 
exception caught when processing request
2004/05/26 20:09:50:563 SGT [WARN] HttpMethodBase - -Recoverable 
exception caught but MethodRetryHandler.retryMethod() returned false, 
rethrow
ing exception
2004/05/26 20:09:50:564 SGT [DEBUG] MultiThreadedHttpConnectionManager - 
-Freeing connection, hostConfig=HostConfiguration[host=somewhere.com, 
protocol=https:443, port=443]
2004/05/26 20:09:50:564 SGT [DEBUG] MultiThreadedHttpConnectionManager - 
-Notifying no-one, there are no waiting threads
org.apache.commons.httpclient.HttpRecoverableException: 
java.net.SocketException: Connection reset
      at 
org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1965) 

      at 
org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBase.java:2659) 

      at 
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1093) 

      at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:675)
      at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:529)
==================================================================

Does anybody know what causes the SocketException ? Is it becos I didn't 
set a higher maximum connection per host using setMaxConnectionsPerHost 
on the MultiThreadedHttpConnectionManager object ?

Pls help. This is urgent as I am currently using it on a production system.

Paul


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


Re: HttpClient problems

Posted by Michael Becke <be...@u.washington.edu>.
> Why is the connection closed here? Who is doing this? The response has 
> not been read yet!

This is because of the exception when writing the request.  
HtttpMethodBase closes connections on exception.

Mike


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


Re: HttpClient problems

Posted by Ortwin Glück <or...@nose.ch>.

paul wrote:

> Ortwin,
> 
> About 1, I have added the changes.
> 
> 2, I need to add some id, pwd into the authentication logic, does 
> httpclient api allow for setting this details?

I don't think there is anything special. You can just create a 
UsernamePasswordCredentials object and add with the HttpState 
#setCredentials method. You might want to set an individual HttpState 
object per execute call as well. You should enable preemtive 
authentication as well. If you do that, set the realm to null in the 
setCredentials method. See API doc for details, and bug 29062 for not 
yet documented stuff : 
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=29062

> 3, Point noted, I will add that in.

I suggest you set up a test system, and run some massive multithreading 
tests against it to reproduce the problem reliably. So you can tell when 
you have fixed the problem.

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


Re: HttpClient problems

Posted by paul <tj...@fairex.com>.
Ortwin,

 About 1, I have added the changes.

2, I need to add some id, pwd into the authentication logic, does 
httpclient api allow for setting this details?

3, Point noted, I will add that in.

Ortwin Glück wrote:

> Some comments on the posted code:
>
> 1. You should execute releaseConnection in a finally block, to ensure 
> the connection is returned to the pool in any case:
>
> PostMethod post = null;
> try {
>   post = new PostMethod(urlAddress);
>   /* ... */
> } finally {
>   if (post != null) post.releaseConnection();
> }
>
> Otherwise you the connection pool might run out of connections if 
> exceptions occur.
>
> 2. You are setting the Authorization header manually. You could use 
> HttpClient's built-in authentication logic instead.
>
> 3. You are setting the encoding in the Content-Type header to 
> ISO-8859-1, but you do not specify any encoding in xmlStr.getBytes(). 
> This assumes that the default platform encoding be ISO-8859-1, which 
> is true for Windows in certain locales but not for most other 
> platforms. Furthermore this assumes your <?xml ?> Header uses 
> encoding="ISO-8859-1", which I can not verify from the code. I suggest 
> you get the XML Stream (not a String) from a DOM directly and specify 
> the same encoding as in the Content-Type header.
>
>
> paul wrote:
>
>> Ortwin,
>>
>>    It seems from the wire logs I gathered, that's the normal behaviour.
>>
>>    I am creating a new HttpMethod object for every send.
>>
>>    Only when I receive the response, then releaseConnection was called.
>>
>>    Here's the code :
>> =================================
>> //convert trade to xml
>>         String xmlStr = convertTradeToXMLString(trade, some1id, someid);
>>
>>         PostMethod post = new PostMethod(urlAddress);
>>         post.setRequestHeader("Content-type", "text/xml; 
>> charset=ISO-8859-1");
>>         post.setRequestHeader ("Authorization", "Basic " + encoding);
>>         post.setRequestHeader("HTTP-Version", "HTTP/1.1");
>>         post.setRequestHeader ("Connection", "Keep-Alive");
>>                xmlInBytes =new ByteArrayInputStream(xmlStr.getBytes());
>>         post.setRequestBody(xmlInBytes);
>>                if (xmlStr.length() < Integer.MAX_VALUE) {
>>            post.setRequestContentLength(xmlStr.length());
>>         }
>>         else {
>>            
>> post.setRequestContentLength(EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED); 
>>
>>         }
>>                // Execute request
>>
>>         toConsole("B4 sending xml, 
>> connMgr.getConnectionsInUse()="+connMgr.getConnectionsInUse());
>>         toConsole(">>>>>>>> Send xml to somewhere @ "+ new 
>> java.sql.Timestamp(System.currentTimeMillis()));
>>         int result = httpClient.executeMethod(post);
>>                //System.out.println("Response body: ");
>>         MQClientConstants.toConsole(">>>>>>>> Reply from fxlink 
>> received @ "+ new java.sql.Timestamp(System.currentTimeMillis()));
>>         String xml = post.getResponseBodyAsString();
>>         post.releaseConnection();
>>
>> =================================
>>
>> Httpclient was created like this :
>> ==================================
>> connMgr = new MultiThreadedHttpConnectionManager();
>>      connMgr.setMaxConnectionsPerHost( MAXHOSTCONNECTIONS );//20 
>> connections
>>      MQClientConstants.toConsole("MultiThreadedHttpConnectionManager 
>> setMaxConnectionsPerHost = "+MAXHOSTCONNECTIONS);
>>
>>      connMgr.setConnectionStaleCheckingEnabled( true );
>>      MQClientConstants.toConsole("MultiThreadedHttpConnectionManager 
>> setConnectionStaleCheckingEnabled = "+true);
>>          httpClient = new HttpClient(connMgr);
>>      httpClient.setTimeout(TIMEOUT);//5 secs
>>      httpClient.setStrictMode(true);
>> ==================================
>>
>> Paul
>
>
>


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


Re: HttpClient problems

Posted by Ortwin Glück <or...@nose.ch>.
Some comments on the posted code:

1. You should execute releaseConnection in a finally block, to ensure 
the connection is returned to the pool in any case:

PostMethod post = null;
try {
   post = new PostMethod(urlAddress);
   /* ... */
} finally {
   if (post != null) post.releaseConnection();
}

Otherwise you the connection pool might run out of connections if 
exceptions occur.

2. You are setting the Authorization header manually. You could use 
HttpClient's built-in authentication logic instead.

3. You are setting the encoding in the Content-Type header to 
ISO-8859-1, but you do not specify any encoding in xmlStr.getBytes(). 
This assumes that the default platform encoding be ISO-8859-1, which is 
true for Windows in certain locales but not for most other platforms. 
Furthermore this assumes your <?xml ?> Header uses 
encoding="ISO-8859-1", which I can not verify from the code. I suggest 
you get the XML Stream (not a String) from a DOM directly and specify 
the same encoding as in the Content-Type header.


paul wrote:
> Ortwin,
> 
>    It seems from the wire logs I gathered, that's the normal behaviour.
> 
>    I am creating a new HttpMethod object for every send.
> 
>    Only when I receive the response, then releaseConnection was called.
> 
>    Here's the code :
> =================================
> //convert trade to xml
>         String xmlStr = convertTradeToXMLString(trade, some1id, someid);
> 
>         PostMethod post = new PostMethod(urlAddress);
>         post.setRequestHeader("Content-type", "text/xml; 
> charset=ISO-8859-1");
>         post.setRequestHeader ("Authorization", "Basic " + encoding);
>         post.setRequestHeader("HTTP-Version", "HTTP/1.1");
>         post.setRequestHeader ("Connection", "Keep-Alive");
>                xmlInBytes =new ByteArrayInputStream(xmlStr.getBytes());
>         post.setRequestBody(xmlInBytes);
>                if (xmlStr.length() < Integer.MAX_VALUE) {
>            post.setRequestContentLength(xmlStr.length());
>         }
>         else {
>            
> post.setRequestContentLength(EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED);
>         }
>                // Execute request
> 
>         toConsole("B4 sending xml, 
> connMgr.getConnectionsInUse()="+connMgr.getConnectionsInUse());
>         toConsole(">>>>>>>> Send xml to somewhere @ "+ new 
> java.sql.Timestamp(System.currentTimeMillis()));
>         int result = httpClient.executeMethod(post);
>                //System.out.println("Response body: ");
>         MQClientConstants.toConsole(">>>>>>>> Reply from fxlink received 
> @ "+ new java.sql.Timestamp(System.currentTimeMillis()));
>         String xml = post.getResponseBodyAsString();
>         post.releaseConnection();
> 
> =================================
> 
> Httpclient was created like this :
> ==================================
> connMgr = new MultiThreadedHttpConnectionManager();
>      connMgr.setMaxConnectionsPerHost( MAXHOSTCONNECTIONS );//20 
> connections
>      MQClientConstants.toConsole("MultiThreadedHttpConnectionManager 
> setMaxConnectionsPerHost = "+MAXHOSTCONNECTIONS);
> 
>      connMgr.setConnectionStaleCheckingEnabled( true );
>      MQClientConstants.toConsole("MultiThreadedHttpConnectionManager 
> setConnectionStaleCheckingEnabled = "+true);
>          httpClient = new HttpClient(connMgr);
>      httpClient.setTimeout(TIMEOUT);//5 secs
>      httpClient.setStrictMode(true);
> ==================================
> 
> Paul


-- 
  _________________________________________________________________
  NOSE applied intelligence ag

  ortwin glück                      [www]      http://www.nose.ch
  software engineer
  hardturmstrasse 171               [pgp id]           0x81CF3416
  8005 zürich                       [office]      +41-1-277 57 35
  switzerland                       [fax]         +41-1-277 57 12

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


Re: HttpClient problems

Posted by paul <tj...@fairex.com>.
Ortwin,

    It seems from the wire logs I gathered, that's the normal behaviour.

    I am creating a new HttpMethod object for every send.

    Only when I receive the response, then releaseConnection was called.

    Here's the code :
=================================
//convert trade to xml
         String xmlStr = convertTradeToXMLString(trade, some1id, someid);

         PostMethod post = new PostMethod(urlAddress);
         post.setRequestHeader("Content-type", "text/xml; 
charset=ISO-8859-1");
         post.setRequestHeader ("Authorization", "Basic " + encoding);
         post.setRequestHeader("HTTP-Version", "HTTP/1.1");
         post.setRequestHeader ("Connection", "Keep-Alive");
        
         xmlInBytes =new ByteArrayInputStream(xmlStr.getBytes());
         post.setRequestBody(xmlInBytes);
        
         if (xmlStr.length() < Integer.MAX_VALUE) {
            post.setRequestContentLength(xmlStr.length());
         }
         else {
            
post.setRequestContentLength(EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED);
         }
        
         // Execute request

         toConsole("B4 sending xml, 
connMgr.getConnectionsInUse()="+connMgr.getConnectionsInUse());
         toConsole(">>>>>>>> Send xml to somewhere @ "+ new 
java.sql.Timestamp(System.currentTimeMillis()));
         int result = httpClient.executeMethod(post);
        
         //System.out.println("Response body: ");
         MQClientConstants.toConsole(">>>>>>>> Reply from fxlink 
received @ "+ new java.sql.Timestamp(System.currentTimeMillis()));
         String xml = post.getResponseBodyAsString();
         post.releaseConnection();

=================================

Httpclient was created like this :
==================================
connMgr = new MultiThreadedHttpConnectionManager();
      connMgr.setMaxConnectionsPerHost( MAXHOSTCONNECTIONS );//20 
connections
      MQClientConstants.toConsole("MultiThreadedHttpConnectionManager 
setMaxConnectionsPerHost = "+MAXHOSTCONNECTIONS);

      connMgr.setConnectionStaleCheckingEnabled( true );
      MQClientConstants.toConsole("MultiThreadedHttpConnectionManager 
setConnectionStaleCheckingEnabled = "+true);
     
      httpClient = new HttpClient(connMgr);
      httpClient.setTimeout(TIMEOUT);//5 secs
      httpClient.setStrictMode(true);
==================================

Paul

Ortwin Glück wrote:

>
>
> paul wrote:
>
>> 2004/05/26 20:09:50:290 SGT [DEBUG] EntityEnclosingMethod - -Request 
>> body sent
>> 2004/05/26 20:09:50:562 SGT [DEBUG] HttpMethodBase - -Closing the 
>> connection.
>
>
> Why is the connection closed here? Who is doing this? The response has 
> not been read yet!
>
> Could this be a threading issue? Are you reusing HttpMethod objects? 
> At what point you call HttpMethod#releaseConnection()?
>
> Any code from your app available?
>
>> 2004/05/26 20:09:50:563 SGT [INFO] HttpMethodBase - -Recoverable 
>> exception caught when processing request
>> 2004/05/26 20:09:50:563 SGT [WARN] HttpMethodBase - -Recoverable 
>> exception caught but MethodRetryHandler.retryMethod() returned false, 
>> rethrow
>> ing exception
>> 2004/05/26 20:09:50:564 SGT [DEBUG] 
>> MultiThreadedHttpConnectionManager - -Freeing connection, 
>> hostConfig=HostConfiguration[host=somewhere.com, protocol=https:443, 
>> port=443]
>> 2004/05/26 20:09:50:564 SGT [DEBUG] 
>> MultiThreadedHttpConnectionManager - -Notifying no-one, there are no 
>> waiting threads
>> org.apache.commons.httpclient.HttpRecoverableException: 
>> java.net.SocketException: Connection reset
>>        at 
>> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1965) 
>
>
>
>


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


Re: HttpClient problems

Posted by Ortwin Glück <or...@nose.ch>.

paul wrote:
> 2004/05/26 20:09:50:290 SGT [DEBUG] EntityEnclosingMethod - -Request 
> body sent
> 2004/05/26 20:09:50:562 SGT [DEBUG] HttpMethodBase - -Closing the 
> connection.

Why is the connection closed here? Who is doing this? The response has 
not been read yet!

Could this be a threading issue? Are you reusing HttpMethod objects? At 
what point you call HttpMethod#releaseConnection()?

Any code from your app available?

> 2004/05/26 20:09:50:563 SGT [INFO] HttpMethodBase - -Recoverable 
> exception caught when processing request
> 2004/05/26 20:09:50:563 SGT [WARN] HttpMethodBase - -Recoverable 
> exception caught but MethodRetryHandler.retryMethod() returned false, 
> rethrow
> ing exception
> 2004/05/26 20:09:50:564 SGT [DEBUG] MultiThreadedHttpConnectionManager - 
> -Freeing connection, hostConfig=HostConfiguration[host=somewhere.com, 
> protocol=https:443, port=443]
> 2004/05/26 20:09:50:564 SGT [DEBUG] MultiThreadedHttpConnectionManager - 
> -Notifying no-one, there are no waiting threads
> org.apache.commons.httpclient.HttpRecoverableException: 
> java.net.SocketException: Connection reset
>        at 
> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1965) 


-- 
  _________________________________________________________________
  NOSE applied intelligence ag

  ortwin glück                      [www]      http://www.nose.ch
  software engineer                 [email] ortwin.glueck@nose.ch
  hardturmstrasse 171               [pgp id]           0x81CF3416
  8005 zürich                       [office]      +41-1-277 57 35
  switzerland                       [fax]         +41-1-277 57 12

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


Re: HttpClient problems

Posted by Paul Wee Tian Jou <tj...@fairex.com>.
Yes, I have set checking enabled to true. 

As for the IIS , I will need to check the logs. 

Is it possible to catch the HttpRecoverableException , and retry the Post 
method again?
-----Original Message-----
From: Michael Becke <be...@u.washington.edu>
To: "Commons HttpClient Project" <commons-httpclient-
dev@jakarta.apache.org>
Date: Thu, 27 May 2004 08:50:18 -0400
Subject: Re: HttpClient problems

> Hi Paul,
> 
> Two quick questions.
> 
>   - Have you set  
> MultiThreadedHttpConnectionManager.setConnectionStaleCheckingEnabled() 
> to false?  If so this could be causing the problem.
> 
>   - It seems that the server is closing the request in mid stream. 
> Have  
> you checked the IIS logs?  There might be something there.
> 
> Mike
> 
> On May 27, 2004, at 8:25 AM, paul wrote:
> 
> > Here's the wire log :
> > ==============================================================
> > 2004/05/26 20:09:50:262 SGT [DEBUG]
> MultiThreadedHttpConnectionManager  
> > - -HttpConnectionManager.getConnection:  config =  
> > HostConfiguration[hos
> > t=somewhere.com, protocol=https:443, port=443], timeout = 0
> > 2004/05/26 20:09:50:262 SGT [DEBUG]
> MultiThreadedHttpConnectionManager  
> > - -Getting free connection,  
> > hostConfig=HostConfiguration[host=somewhere.com, protocol=https:443, 
> > port=443]
> > 2004/05/26 20:09:50:263 SGT [DEBUG] HttpConnection -  
> > -HttpConnection.setSoTimeout(0)
> > 2004/05/26 20:09:50:270 SGT [DEBUG] HttpMethodBase - -Execute loop
> try  
> > 1
> > 2004/05/26 20:09:50:280 SGT [DEBUG] wire - ->> "POST  
> > /fxlweb/XMLGateway.asp HTTP/1.1[\r][\n]"
> > 2004/05/26 20:09:50:281 SGT [DEBUG] HttpMethodBase - -Adding Host  
> > request header
> > 2004/05/26 20:09:50:282 SGT [DEBUG] wire - ->> "Content-type:  
> > text/xml; charset=ISO-8859-1[\r][\n]"
> > 2004/05/26 20:09:50:283 SGT [DEBUG] wire - ->> "Authorization: Basic 
> > someencrypteddata[\r][\n]"
> > 2004/05/26 20:09:50:283 SGT [DEBUG] wire - ->> "HTTP-Version:  
> > HTTP/1.1[\r][\n]"
> > 2004/05/26 20:09:50:284 SGT [DEBUG] wire - ->> "Connection:  
> > Keep-Alive[\r][\n]"
> > 2004/05/26 20:09:50:285 SGT [DEBUG] wire - ->> "User-Agent: Jakarta  
> > Commons-HttpClient/2.0final[\r][\n]"
> > 2004/05/26 20:09:50:286 SGT [DEBUG] wire - ->> "Host:  
> > somewhere.com[\r][\n]"
> > 2004/05/26 20:09:50:287 SGT [DEBUG] wire - ->> "Cookie: $Version=0;  
> > ASPSESSIONIDAACRQATR=DKBJEFCAIKAHLGIMJKIBEGBH; $Path=/[\r][\n]"
> > 2004/05/26 20:09:50:287 SGT [DEBUG] wire - ->> "Content-Length:  
> > 594[\r][\n]"
> > 2004/05/26 20:09:50:288 SGT [DEBUG] wire - ->> "[\r][\n]"
> > 2004/05/26 20:09:50:289 SGT [DEBUG] EntityEnclosingMethod - -Using  
> > unbuffered request body
> > 2004/05/26 20:09:50:290 SGT [DEBUG] wire - ->> "<?xml version="1.0"  
> > encoding="UTF-8"?>xmldata here"
> > 2004/05/26 20:09:50:290 SGT [DEBUG] EntityEnclosingMethod - -Request 
> > body sent
> > 2004/05/26 20:09:50:562 SGT [DEBUG] HttpMethodBase - -Closing the  
> > connection.
> > 2004/05/26 20:09:50:563 SGT [INFO] HttpMethodBase - -Recoverable  
> > exception caught when processing request
> > 2004/05/26 20:09:50:563 SGT [WARN] HttpMethodBase - -Recoverable  
> > exception caught but MethodRetryHandler.retryMethod() returned false,
>  
> > rethrow
> > ing exception
> > 2004/05/26 20:09:50:564 SGT [DEBUG]
> MultiThreadedHttpConnectionManager  
> > - -Freeing connection,  
> > hostConfig=HostConfiguration[host=somewhere.com, protocol=https:443, 
> > port=443]
> > 2004/05/26 20:09:50:564 SGT [DEBUG]
> MultiThreadedHttpConnectionManager  
> > - -Notifying no-one, there are no waiting threads
> > org.apache.commons.httpclient.HttpRecoverableException:  
> > java.net.SocketException: Connection reset
> >        at  
> >
> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBas
> > e.java:1965)
> >        at  
> >
> org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodB
> > ase.java:2659)
> >        at  
> >
> org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.jav
> > a:1093)
> >        at  
> >
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:
> > 675)
> >        at  
> >
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:
> > 529)
> >
> > =============================================================
> > Thanks a lot for the info.
> >
> > Ortwin Glück wrote:
> >
> >>
> >>
> >> paul wrote:
> >>
> >>> 2004/05/26 20:09:50:564 SGT [DEBUG]  
> >>> MultiThreadedHttpConnectionManager - -Notifying no-one, there are
> no  
> >>> waiting threads
> >>> org.apache.commons.httpclient.HttpRecoverableException:  
> >>> java.net.SocketException: Connection reset
> >>>      at  
> >>>
> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodB 
> >>> ase.java:1965)
> >>>      at  
> >>>
> org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMetho 
> >>> dBase.java:2659)
> >>
> >>
> >>
> >>
> >>> Does anybody know what causes the SocketException ?
> >>
> >>
> >> Not yet, but we're gonna find out for you :-)
> >>
> >> Please produce a wirelog and send the section with the request /  
> >> response immediately preceding the exception.
> >> For instructions about how to make a wirelog please see our Logging 
> >> Guide:
> >> http://jakarta.apache.org/commons/httpclient/logging.html
> >>
> >> Please note that wire logging will slow down your application  
> >> considerably! This is escpecially bad, because the problem you are  
> >> experiencing seems to happen randomly. Please make sure you disable 
> >> logging after you have successfully captured the output.
> >>
> >>
> >>> Is it becos I didn't
> >>> set a higher maximum connection per host using  
> >>> setMaxConnectionsPerHost on the MultiThreadedHttpConnectionManager 
> >>> object ?
> >>
> >>
> >> Probably not - just doesn't look like it.
> >>
> >>> Pls help. This is urgent as I am currently using it on a production
>  
> >>> system.
> >>
> >>
> >> You are welcome. Maybe we should start offering commercial support  
> >> and make A LOT of money :-)
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail:  
> > commons-httpclient-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:  
> > commons-httpclient-dev-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-httpclient-dev-help@jakarta.apache.org


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


Re: HttpClient problems

Posted by Michael Becke <be...@u.washington.edu>.
Hi Paul,

Two quick questions.

  - Have you set  
MultiThreadedHttpConnectionManager.setConnectionStaleCheckingEnabled()  
to false?  If so this could be causing the problem.

  - It seems that the server is closing the request in mid stream.  Have  
you checked the IIS logs?  There might be something there.

Mike

On May 27, 2004, at 8:25 AM, paul wrote:

> Here's the wire log :
> ==============================================================
> 2004/05/26 20:09:50:262 SGT [DEBUG] MultiThreadedHttpConnectionManager  
> - -HttpConnectionManager.getConnection:  config =  
> HostConfiguration[hos
> t=somewhere.com, protocol=https:443, port=443], timeout = 0
> 2004/05/26 20:09:50:262 SGT [DEBUG] MultiThreadedHttpConnectionManager  
> - -Getting free connection,  
> hostConfig=HostConfiguration[host=somewhere.com, protocol=https:443,  
> port=443]
> 2004/05/26 20:09:50:263 SGT [DEBUG] HttpConnection -  
> -HttpConnection.setSoTimeout(0)
> 2004/05/26 20:09:50:270 SGT [DEBUG] HttpMethodBase - -Execute loop try  
> 1
> 2004/05/26 20:09:50:280 SGT [DEBUG] wire - ->> "POST  
> /fxlweb/XMLGateway.asp HTTP/1.1[\r][\n]"
> 2004/05/26 20:09:50:281 SGT [DEBUG] HttpMethodBase - -Adding Host  
> request header
> 2004/05/26 20:09:50:282 SGT [DEBUG] wire - ->> "Content-type:  
> text/xml; charset=ISO-8859-1[\r][\n]"
> 2004/05/26 20:09:50:283 SGT [DEBUG] wire - ->> "Authorization: Basic  
> someencrypteddata[\r][\n]"
> 2004/05/26 20:09:50:283 SGT [DEBUG] wire - ->> "HTTP-Version:  
> HTTP/1.1[\r][\n]"
> 2004/05/26 20:09:50:284 SGT [DEBUG] wire - ->> "Connection:  
> Keep-Alive[\r][\n]"
> 2004/05/26 20:09:50:285 SGT [DEBUG] wire - ->> "User-Agent: Jakarta  
> Commons-HttpClient/2.0final[\r][\n]"
> 2004/05/26 20:09:50:286 SGT [DEBUG] wire - ->> "Host:  
> somewhere.com[\r][\n]"
> 2004/05/26 20:09:50:287 SGT [DEBUG] wire - ->> "Cookie: $Version=0;  
> ASPSESSIONIDAACRQATR=DKBJEFCAIKAHLGIMJKIBEGBH; $Path=/[\r][\n]"
> 2004/05/26 20:09:50:287 SGT [DEBUG] wire - ->> "Content-Length:  
> 594[\r][\n]"
> 2004/05/26 20:09:50:288 SGT [DEBUG] wire - ->> "[\r][\n]"
> 2004/05/26 20:09:50:289 SGT [DEBUG] EntityEnclosingMethod - -Using  
> unbuffered request body
> 2004/05/26 20:09:50:290 SGT [DEBUG] wire - ->> "<?xml version="1.0"  
> encoding="UTF-8"?>xmldata here"
> 2004/05/26 20:09:50:290 SGT [DEBUG] EntityEnclosingMethod - -Request  
> body sent
> 2004/05/26 20:09:50:562 SGT [DEBUG] HttpMethodBase - -Closing the  
> connection.
> 2004/05/26 20:09:50:563 SGT [INFO] HttpMethodBase - -Recoverable  
> exception caught when processing request
> 2004/05/26 20:09:50:563 SGT [WARN] HttpMethodBase - -Recoverable  
> exception caught but MethodRetryHandler.retryMethod() returned false,  
> rethrow
> ing exception
> 2004/05/26 20:09:50:564 SGT [DEBUG] MultiThreadedHttpConnectionManager  
> - -Freeing connection,  
> hostConfig=HostConfiguration[host=somewhere.com, protocol=https:443,  
> port=443]
> 2004/05/26 20:09:50:564 SGT [DEBUG] MultiThreadedHttpConnectionManager  
> - -Notifying no-one, there are no waiting threads
> org.apache.commons.httpclient.HttpRecoverableException:  
> java.net.SocketException: Connection reset
>        at  
> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBas 
> e.java:1965)
>        at  
> org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodB 
> ase.java:2659)
>        at  
> org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.jav 
> a:1093)
>        at  
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java: 
> 675)
>        at  
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java: 
> 529)
>
> =============================================================
> Thanks a lot for the info.
>
> Ortwin Glück wrote:
>
>>
>>
>> paul wrote:
>>
>>> 2004/05/26 20:09:50:564 SGT [DEBUG]  
>>> MultiThreadedHttpConnectionManager - -Notifying no-one, there are no  
>>> waiting threads
>>> org.apache.commons.httpclient.HttpRecoverableException:  
>>> java.net.SocketException: Connection reset
>>>      at  
>>> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodB 
>>> ase.java:1965)
>>>      at  
>>> org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMetho 
>>> dBase.java:2659)
>>
>>
>>
>>
>>> Does anybody know what causes the SocketException ?
>>
>>
>> Not yet, but we're gonna find out for you :-)
>>
>> Please produce a wirelog and send the section with the request /  
>> response immediately preceding the exception.
>> For instructions about how to make a wirelog please see our Logging  
>> Guide:
>> http://jakarta.apache.org/commons/httpclient/logging.html
>>
>> Please note that wire logging will slow down your application  
>> considerably! This is escpecially bad, because the problem you are  
>> experiencing seems to happen randomly. Please make sure you disable  
>> logging after you have successfully captured the output.
>>
>>
>>> Is it becos I didn't
>>> set a higher maximum connection per host using  
>>> setMaxConnectionsPerHost on the MultiThreadedHttpConnectionManager  
>>> object ?
>>
>>
>> Probably not - just doesn't look like it.
>>
>>> Pls help. This is urgent as I am currently using it on a production  
>>> system.
>>
>>
>> You are welcome. Maybe we should start offering commercial support  
>> and make A LOT of money :-)
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:  
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:  
> commons-httpclient-dev-help@jakarta.apache.org
>


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


Re: HttpClient problems

Posted by paul <tj...@fairex.com>.
Here's the wire log :
==============================================================
2004/05/26 20:09:50:262 SGT [DEBUG] MultiThreadedHttpConnectionManager - 
-HttpConnectionManager.getConnection:  config = HostConfiguration[hos
t=somewhere.com, protocol=https:443, port=443], timeout = 0
2004/05/26 20:09:50:262 SGT [DEBUG] MultiThreadedHttpConnectionManager - 
-Getting free connection, 
hostConfig=HostConfiguration[host=somewhere.com, protocol=https:443, 
port=443]
2004/05/26 20:09:50:263 SGT [DEBUG] HttpConnection - 
-HttpConnection.setSoTimeout(0)
2004/05/26 20:09:50:270 SGT [DEBUG] HttpMethodBase - -Execute loop try 1
2004/05/26 20:09:50:280 SGT [DEBUG] wire - ->> "POST 
/fxlweb/XMLGateway.asp HTTP/1.1[\r][\n]"
2004/05/26 20:09:50:281 SGT [DEBUG] HttpMethodBase - -Adding Host 
request header
2004/05/26 20:09:50:282 SGT [DEBUG] wire - ->> "Content-type: text/xml; 
charset=ISO-8859-1[\r][\n]"
2004/05/26 20:09:50:283 SGT [DEBUG] wire - ->> "Authorization: Basic 
someencrypteddata[\r][\n]"
2004/05/26 20:09:50:283 SGT [DEBUG] wire - ->> "HTTP-Version: 
HTTP/1.1[\r][\n]"
2004/05/26 20:09:50:284 SGT [DEBUG] wire - ->> "Connection: 
Keep-Alive[\r][\n]"
2004/05/26 20:09:50:285 SGT [DEBUG] wire - ->> "User-Agent: Jakarta 
Commons-HttpClient/2.0final[\r][\n]"
2004/05/26 20:09:50:286 SGT [DEBUG] wire - ->> "Host: somewhere.com[\r][\n]"
2004/05/26 20:09:50:287 SGT [DEBUG] wire - ->> "Cookie: $Version=0; 
ASPSESSIONIDAACRQATR=DKBJEFCAIKAHLGIMJKIBEGBH; $Path=/[\r][\n]"
2004/05/26 20:09:50:287 SGT [DEBUG] wire - ->> "Content-Length: 594[\r][\n]"
2004/05/26 20:09:50:288 SGT [DEBUG] wire - ->> "[\r][\n]"
2004/05/26 20:09:50:289 SGT [DEBUG] EntityEnclosingMethod - -Using 
unbuffered request body
2004/05/26 20:09:50:290 SGT [DEBUG] wire - ->> "<?xml version="1.0" 
encoding="UTF-8"?>xmldata here"
2004/05/26 20:09:50:290 SGT [DEBUG] EntityEnclosingMethod - -Request 
body sent
2004/05/26 20:09:50:562 SGT [DEBUG] HttpMethodBase - -Closing the 
connection.
2004/05/26 20:09:50:563 SGT [INFO] HttpMethodBase - -Recoverable 
exception caught when processing request
2004/05/26 20:09:50:563 SGT [WARN] HttpMethodBase - -Recoverable 
exception caught but MethodRetryHandler.retryMethod() returned false, 
rethrow
ing exception
2004/05/26 20:09:50:564 SGT [DEBUG] MultiThreadedHttpConnectionManager - 
-Freeing connection, hostConfig=HostConfiguration[host=somewhere.com, 
protocol=https:443, port=443]
2004/05/26 20:09:50:564 SGT [DEBUG] MultiThreadedHttpConnectionManager - 
-Notifying no-one, there are no waiting threads
org.apache.commons.httpclient.HttpRecoverableException: 
java.net.SocketException: Connection reset
        at 
org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1965)
        at 
org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBase.java:2659)
        at 
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1093)
        at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:675)
        at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:529)
       

=============================================================
Thanks a lot for the info.

Ortwin Glück wrote:

>
>
> paul wrote:
>
>> 2004/05/26 20:09:50:564 SGT [DEBUG] 
>> MultiThreadedHttpConnectionManager - -Notifying no-one, there are no 
>> waiting threads
>> org.apache.commons.httpclient.HttpRecoverableException: 
>> java.net.SocketException: Connection reset
>>      at 
>> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1965) 
>>
>>      at 
>> org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBase.java:2659) 
>
>
>
>
>> Does anybody know what causes the SocketException ? 
>
>
> Not yet, but we're gonna find out for you :-)
>
> Please produce a wirelog and send the section with the request / 
> response immediately preceding the exception.
> For instructions about how to make a wirelog please see our Logging 
> Guide:
> http://jakarta.apache.org/commons/httpclient/logging.html
>
> Please note that wire logging will slow down your application 
> considerably! This is escpecially bad, because the problem you are 
> experiencing seems to happen randomly. Please make sure you disable 
> logging after you have successfully captured the output.
>
>
>> Is it becos I didn't
>> set a higher maximum connection per host using 
>> setMaxConnectionsPerHost on the MultiThreadedHttpConnectionManager 
>> object ?
>
>
> Probably not - just doesn't look like it.
>
>> Pls help. This is urgent as I am currently using it on a production 
>> system.
>
>
> You are welcome. Maybe we should start offering commercial support and 
> make A LOT of money :-)
>


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


Re: HttpClient problems

Posted by Ortwin Glück <or...@nose.ch>.

paul wrote:

> 2004/05/26 20:09:50:564 SGT [DEBUG] MultiThreadedHttpConnectionManager - 
> -Notifying no-one, there are no waiting threads
> org.apache.commons.httpclient.HttpRecoverableException: 
> java.net.SocketException: Connection reset
>      at 
> org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1965) 
> 
>      at 
> org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBase.java:2659) 


> Does anybody know what causes the SocketException ? 

Not yet, but we're gonna find out for you :-)

Please produce a wirelog and send the section with the request / 
response immediately preceding the exception.
For instructions about how to make a wirelog please see our Logging Guide:
http://jakarta.apache.org/commons/httpclient/logging.html

Please note that wire logging will slow down your application 
considerably! This is escpecially bad, because the problem you are 
experiencing seems to happen randomly. Please make sure you disable 
logging after you have successfully captured the output.


> Is it becos I didn't
> set a higher maximum connection per host using setMaxConnectionsPerHost 
> on the MultiThreadedHttpConnectionManager object ?

Probably not - just doesn't look like it.

> Pls help. This is urgent as I am currently using it on a production system.

You are welcome. Maybe we should start offering commercial support and 
make A LOT of money :-)

-- 
  _________________________________________________________________
  NOSE applied intelligence ag

  ortwin glück                      [www]      http://www.nose.ch
  software engineer                 [email] ortwin.glueck@nose.ch
  hardturmstrasse 171               [pgp id]           0x81CF3416
  8005 zürich                       [office]      +41-1-277 57 35
  switzerland                       [fax]         +41-1-277 57 12

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