commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Max Johnson" <>
Subject RE: HttpClient stability issues?
Date Fri, 23 May 2003 12:55:50 GMT
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);

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


-----Original Message-----
From: Walther, Benjamin []
Sent: 23 May 2003 13:42
To: '';
Subject: HttpClient stability issues?


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);
			  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
		   logDebug( "HttpConnectionManager.doPost: Response from
		finally {
			// Release the connection.

View raw message