Closed gregrluck closed 14 years ago
Hi Greg! Nice to see you here! We had already a unit test that cover that API, but I've just added another one here:
In you code snippet above you set the max to 1, meaning only one connection will be allowed if keep-alive is used, hence the exception. Can you describe what you were expected? Maybe I need to clarify the docs.
Thanks!
-- Jeanfrancois
JF
Yes, I am full-time on Ehcache these days, although I still don't seem to be coding that much more. The intent of the code I wrote was to use 10 connections to Jetty and rip through 10,000 gets as fast as possible. I was hoping to set the maximum number of connections to 10 so as not to overwhelm Jetty.
BTW, the result so far with HttpClient is line ball with Memcache.
So it doesn't do what you want? Can you take a look at the unit test and see if you can share a test that reproduce the issue? Thanks
I'm closing the issue as a non issue. Please re-open if you think the current behavior is wrong.
Hi Jean-Francois :)
I have this code:
AsyncHttpClientConfig asyncHttpClientConfig = new AsyncHttpClientConfig.Builder(). setKeepAlive(true).setConnectionTimeoutInMs(1000).setMaximumConnectionsTotal(1).build(); AsyncHttpClient asyncHttpClient = new AsyncHttpClient(asyncHttpClientConfig);
// LOG.info("Request " + i); // openConnections.incrementAndGet(); // if (openConnections.get() <= 1) { asyncHttpClient.prepareGet(url).execute(new AsyncCompletionHandler() {
// }
I get:
java.io.IOException: Too many connections at com.ning.http.client.providers.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:495) at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:291) at com.ning.http.client.AsyncHttpClient$BoundRequestBuilder.execute(AsyncHttpClient.java:192) at net.sf.ehcache.server.rest.resources.SpeedTest.testMemCachedBench(SpeedTest.java:213) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
But when I control myself the maximum number of open connections and limit those to 10 it works fine. So it seems to me that setMaximumConnectionsTotal() is not working.