hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Max Johnson" <max.john...@flytxt.com>
Subject RE: HttpClient stability issues?
Date Fri, 23 May 2003 13:49:00 GMT
Just noticed from looking at the code again that you need to increment your
attempt count before executing the method, not after :)


-----Original Message-----
From: Kalnichevski, Oleg [mailto:oleg.kalnichevski@bearingpoint.com]
Sent: 23 May 2003 14:24
To: Commons HttpClient Project
Subject: RE: HttpClient stability issues?


Benjamin,

Just a short follow-up to the Max's comment.

The HTTP server MAY drop connections pretty much at any time without having
to notify the HTTP client. This kind of behavior is perfectly valid from the
HTTP specification standpoint. As the client has no way of knowing if the
connection is still ok, an attempt to reuse a stale connection will result
in broken pipe I/O exception thrown. This is not a bug, and not a stability
issue either. However, this said, a lot of work has been done since 2.0a3
release to make sure that HttpClient can recover gracefully from
encountering a stale connection. Just bear with us for a little while as
beta-1 release is imminent.

Cheers

Oleg

-----Original Message-----
From: Max Johnson [mailto:max.johnson@flytxt.com]
Sent: Friday, May 23, 2003 14:56
To: Commons HttpClient Project; commons-user@jakarta.apache.org
Subject: RE: HttpClient stability issues?


You need to recycle your POST method before you perform a retry attempt. So
your catch block would look something like this:

  catch (HttpRecoverableException e) {
	logInfo( "A recoverable exception occurred, retrying." + e);
	method.recycle();
	method.setPath(url.toString());
  }

Alpha 3 build has problems though so it's worth upgrading to the latest
nightly build too.

Max

-----Original Message-----
From: Walther, Benjamin [mailto:Benjamin.Walther@sunrise.net]
Sent: 23 May 2003 13:42
To: 'commons-httpclient-dev@jakarta.apache.org';
'commons-user@jakarta.apache.org'
Subject: HttpClient stability issues?


Hi,


I use httpclient like described in the tutorial. I have a session scoped
class that creates a httpclient instance upon creation time. It then nvokes
methods on this client instance.

Unfortunately it behaves very unstable. I use the releasse 2.0 alpha 3 .
When invoking the execute method  i get
IOException: broken pipe or org.apache.commons.httpclient.HttpException:
Already used, but not recycled.
Any idea?
My code looks like:
public void doPost(URL url, String postBody, Writer writer ) throws
IOException {
PostMethod method = new PostMethod(url.toString());
		try {
			method.setRequestBody( postBody );
// Execute the method.
			int statusCode = -1;
			int attempt = 0;
			// We will retry up to 3 times.
			while (statusCode == -1 && attempt < 3) {
			  try {
				// execute the method.
				statusCode = client.executeMethod(method);
				attempt++;
			  }
			  catch (HttpRecoverableException e) {
				logInfo( "A recoverable exception occurred,
retrying." + e);
			  }
			  catch (IOException e) {
				logError("Failed to connect to
url:"+url.toString()+" Error:"+e);
				throw e;
			  }
			}
			// Check that we didn't run out of retries.

			if ( statusCode != HttpStatus.SC_OK){
				if (statusCode == -1) {
				  logError("Failed to recover from
exception. See info.log");
				}
				//Vitria sends only HttpStatus.SC_OK back
when no error therefore no action here
				logInfo("Status from Vitria not OK(200).
Status was:"+statusCode);
			}

			// Deal with the response.
		   // Use caution: ensure correct character encoding and is
not binary data
		   copyStreamToCharWriter(method.getResponseBodyAsStream(),
writer);
		   logDebug( "HttpConnectionManager.doPost: Response from
url:"+url.toString()+":"+writer.toString());
		}
		finally {
			// Release the connection.
				method.releaseConnection();
		}
}



---------------------------------------------------------------------
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


Mime
View raw message