hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Walther, Benjamin" <Benjamin.Walt...@sunrise.net>
Subject HttpClient stability issues?
Date Fri, 23 May 2003 12:41:53 GMT
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();	
		}
}


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message