I'm having trouble with some code I'm testing using AsyncHTTPClient. Here is the general config
this.config = (new AsyncHttpClientConfig.Builder())
.setAllowPoolingConnection(true)
.setAllowSslConnectionPool(true)
.addRequestFilter(new ThrottleRequestFilter(10))
.setMaximumConnectionsPerHost(20)
//.setMaximumConnectionsTotal(20)
.setRequestTimeoutInMs(100000)
.build();
this.client = new AsyncHttpClient(new NettyAsyncHttpProvider(config));
(Note that max connections is commented out because of some weird bug when using ThrottleRequestFilter, see here https://groups.google.com/forum/?fromgroups=#!topic/asynchttpclient/nEnQnPtCP2g)
Now here is some test code,
FileInputStream fstream = new FileInputStream("import.txt");
DataInputStream dstream = new DataInputStream(fstream);
BufferedReader reader = new BufferedReader(new InputStreamReader(dstream));
while ((line = reader.readLine()) != null) {
//Some code to build and create a request using the build function and then perform a GET operation. Request is built using Java's Future object from java.concurrent
}
When the import.txt file is less than 100 lines of simple text such as this
196 242 3 881250949
Everything works fine, all the requests go through and when you check the responses all is fine. Anything over 100 and I start getting timeouts and in cases of something like 1000+, I actually start running into permGen memory errors.
I thought the ThrottleRequestFilter is supposed to limit the max threads to 10 and process only 10 at a time. Why does it bomb out when the text file has more than 100+ lines?
I've also tried switching to using the Grizzly implementation but that also bombs out the same way. I'm beginning to suspect it's either the way I wrote the test code or Async HTTP Client actually has some issues when creating a high number of requests. If so, are there any other good async http clients for java?