Hello Hakan, the code looks ok, form a connection management perspective. Are you sure this is the only place where requests are executed and connections get allocated?
You should initialize the StringBuffer with a size somewhere in the range of the expected page size. Otherwise the StringBuffer will frequently re-allocate memory to copy characters into a larger array. cheers, Roland Hakan Isikhan <[EMAIL PROTECTED]> 06.04.2006 11:37 Please respond to "HttpClient User Discussion" To HttpClient User Discussion <[email protected]> cc 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 <[EMAIL PROTECTED]> 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: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
