micronaut-projects / micronaut-core

Micronaut Application Framework
http://micronaut.io
Apache License 2.0
6.04k stars 1.06k forks source link

DefaultHttpClient.proxy ignores connection pool limits #7028

Open bwertman-rc opened 2 years ago

bwertman-rc commented 2 years ago

Expected Behavior

I would like to limit the active concurrent connections to an upstream server when proxying requests using a DefaultHttpClient, preferably by setting a connection limit in its configuration.

Alternately, I could use the normal exchange methods on DefaultHttpClient (which presumably respect the configured limits) if the proxied request rewriting was extracted into a separate class for reusability.

Actual Behaviour

I tried enabling the client's connection pool and setting a limit, but during testing I found it wasn't being respected. Stepping though the code in a debugger, it seems that poolMap isn't accessed at all.

Steps To Reproduce

Configure a HttpClientConfiguration's connection pool to enable it and set a limit on the number of connections.

HttpClientConfiguration config = new DefaultHttpClientConfiguration();
ConnectionPoolConfiguration conn = config.getConnectionPoolConfiguration();
conn.setEnabled(true);
conn.setMaxConnections(maxConcurrentRequests);

Use that configuration to create a proxy client

ProxyHttpClient proxyClient = ProxyHttpClient.create(url, config);

Proxy requests through the client, and see more connections than the configured pool size.

Environment Information

Example Application

No response

Version

3.3.4

yawkat commented 2 years ago

yes the proxy client doesn't participate in connection pooling. pooling for the http client in general needs some work