hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ingo Meyer" <dj-sl...@gmx.net>
Subject AW: thread hangs after several connection timeout
Date Thu, 06 Apr 2006 14:37:41 GMT
> -----Urspr√ľngliche Nachricht-----
> Von: Steve Terrell [mailto:Steven.Terrell@guideworkstv.com] 
> Gesendet: Donnerstag, 6. April 2006 16:14
> An: HttpClient User Discussion
> Betreff: RE: thread hangs after several connection timeout
> 
> Hakan,
>    After calling executeMethod, you are checking for the 
> statusCode. In the case where statusCode is not SC_OK, you 
> return without releasing the connection. That could be part 
> of the problem.
> 
> --Steve

Hi Steve,

that's not right!!!
when returning from an try/catch block the finally statement is ALWAYS
executed.
Use a debugger to see this...

greets
Ingo Meyer

> -----Original Message-----
> From: Hakan Isikhan [mailto:c0redumper@yahoo.com]
> Sent: Thursday, April 06, 2006 5:37 AM
> To: HttpClient User Discussion
> Subject: Re: thread hangs after several connection timeout
> 
> 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
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> httpclient-user-help@jakarta.apache.org
> 


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