hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hakan Isikhan <c0redum...@yahoo.com>
Subject Re: thread hangs after several connection timeout
Date Thu, 06 Apr 2006 09:37:11 GMT
Hi Roland,
Thanks for reply. below is the code partion from my
app. i release connection in finally block. i use
httpclient 3.0. please check my code and i would like
to hear your ideas. thank you again for your interest.

  // single httpclient instance from a
MultiThreadedHttpConnectionManager
  PostMethod post = new PostMethod(serverURL);
  //post add parameters....

		try {

			int statusCode = client.executeMethod(post);

			if (statusCode != HttpStatus.SC_OK) {
				return null;
			}

			// Read the response body.
			InputStream in = post.getResponseBodyAsStream();
			StringBuffer sb = new StringBuffer();
			char ch;
			int i;
			while ((i = in.read()) > -1) {
				sb.append((char) i);
			}

	            //process response

		} catch (Exception e) {
               e.printStackTrace();
		} finally {
			post.releaseConnection();
		}

--- Roland Weber <ROLWEBER@de.ibm.com> wrote:

> Hello Hakan,
> 
> > if some thread gets connection timeout , let's say
> > more than 5 times, thread just hangs. i donot use
> any
> > retry manager or something like that. my threads
> do
> > not reach run() method's exit block. i need to
> > reinitiate stop all other threads and start again
> > manually.
> > 
> > what could be the reason ?
> 
> You probably do not release the connection if you
> get
> a connection timeout. Make sure the call to release
> the connection is in a finally{} block. Otherwise,
> each connection timeout leaks a connection, and your
> thread blocks when no more connections are
> available.
> 
> hope that helps,
>   Roland
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> httpclient-user-help@jakarta.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Mime
View raw message