On Mon, May 18, 2009 at 09:13:28AM -0700, DerekC wrote: > > Hi all, > > I'm using HttpComponents 4 and I'm getting the following error if I wait > more than 15 seconds between 2 HTTP GET requests: > org.apache.http.NoHttpResponseException: The target server failed to respond > If I use HTTPClient 3.1 then the error is not the same: Connection is > stale,closing... > With HTTPClient 3.1, there is no exception, the connection seems closed and > the application can go ahead. >
Hi Derek The stale connection checking should work exactly the same way as with HttpClient 3.1. Could you please produce a wire / context log of the session and post it to the list? http://hc.apache.org/httpcomponents-client/logging.html > I think the problem is related to "Keep-Alive" management from server-side. > What do you think about ? > What parameters could I pass to HTTPComponents 4 to have the same behavior > as HTTPClient 3.1 ? > > I've tried to use the following parameters without success: > params = new BasicHttpParams(); > ConnManagerParams.setMaxTotalConnections(params, 2); > HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); > HttpProtocolParams.setUseExpectContinue(params, false); > HttpConnectionParams.setStaleCheckingEnabled(params, true); > > SchemeRegistry schemeRegistry = new SchemeRegistry(); > schemeRegistry.register(new Scheme("http", > PlainSocketFactory.getSocketFactory(), 80)); > schemeRegistry.register(new Scheme("https", > SSLSocketFactory.getSocketFactory(), 443)); > manager = new ThreadSafeClientConnManager(params, schemeRegistry); > client = new DefaultHttpClient(manager, params); > client.setReuseStrategy(new ConnectionReuseStrategy(){ > public boolean keepAlive(HttpResponse arg0, HttpContext arg1) { > return false; > } > }); > > Any advice would be welcome. > You should be using ConnectionKeepAliveStrategy to set the keep alive to a reasonable value instead of disabling connection persistence altogether: http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/conn/ConnectionKeepAliveStrategy.html Hope this helps Oleg > Derek. > -- > View this message in context: > http://www.nabble.com/The-target-server-failed-to-respond---What-could-be-the-problem---tp23600284p23600284.html > Sent from the HttpClient-User mailing list archive at Nabble.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]
