Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freeChannels isn't being released (Netty) #831

Closed
marenzo opened this issue Feb 26, 2015 · 4 comments
Closed

freeChannels isn't being released (Netty) #831

marenzo opened this issue Feb 26, 2015 · 4 comments

Comments

@marenzo
Copy link
Contributor

marenzo commented Feb 26, 2015

For some reason, the following code:

    AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder().setMaxConnections(200).setMaxConnectionsPerHost(100).build();
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient(config);
    for (int i = 0; i < 140; i++) {
      asyncHttpClient.prepareGet("http://localhost/page.html").execute(new AsyncCompletionHandler<Response>(){

        @Override
        public Response onCompleted(Response response) throws Exception{
          System.out.println("Completed");
          return response;
        }

        @Override
        public void onThrowable(Throwable t){
          System.out.println(t.getMessage());
        }
      }).get();
    }

Will throw the following exception: java.io.IOException: Too many connections per host 100

As its seems, abortChannelPreemption (in NettyConnectListener) is never being called because the condition if (future.isDone()) is always false, thus freeChannels (ChannelManager) never being released.

Happens on AHC 1.9.10, Java version "1.7.0_65".

@marenzo marenzo changed the title freeChannels doesn't being released (Netty) freeChannels isn't being released (Netty) Feb 26, 2015
@slandelle
Copy link
Contributor

Please upgrade to 1.9.11: #820

@marenzo
Copy link
Contributor Author

marenzo commented Feb 26, 2015

Thanks for the fast reply!

@srirama-rayaprolu
Copy link

Hi

Here the code inside the for loop is blocked.(as get() is called on the future). While executing this piece of code, if checked for the netstat , it would show only one connection.

If for loop is executed in asynchronous way the problem of IO exception is coming. How to control this.

Pl. correct me if I am wrong.

Thanks in advance.

@slandelle
Copy link
Contributor

@srirama-rayaprolu AHC maxConnection mechanism is a security, it doesn't come with a queue for buffering the excessive requests. If you want one, you have to write one. Contributions welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants