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

Suggest adjusting the parameters default value #254

Open
jackqh opened this issue Oct 23, 2024 · 1 comment
Open

Suggest adjusting the parameters default value #254

jackqh opened this issue Oct 23, 2024 · 1 comment

Comments

@jackqh
Copy link

jackqh commented Oct 23, 2024

the maxConnections default value is -1, value - 1 usually means no limit in tomcat, but the maxConnTotal value in HttpClientBuilder must greater than 0 , if i dont config maxConnections , i got the max request per route is 5,The value is too low for online service.

org.mitre.dsmiley.httpproxy.ProxyServlet

 protected int maxConnections = -1;
 protected HttpClient createHttpClient() {
    HttpClientBuilder clientBuilder = getHttpClientBuilder()
                                        .setDefaultRequestConfig(buildRequestConfig())
                                        .setDefaultSocketConfig(buildSocketConfig());

    clientBuilder.setMaxConnTotal(maxConnections);
    clientBuilder.setMaxConnPerRoute(maxConnections);
    if(! doHandleCompression) {
      clientBuilder.disableContentCompression();
    }

    if (useSystemProperties)
      clientBuilder = clientBuilder.useSystemProperties();
    return buildHttpClient(clientBuilder);
  }

org/apache/http/impl/client/HttpClientBuilder.java

 if (systemProperties) {
      String s = System.getProperty("http.keepAlive", "true");
      if ("true".equalsIgnoreCase(s)) {
          s = System.getProperty("http.maxConnections", "5");
          final int max = Integer.parseInt(s);
          poolingmgr.setDefaultMaxPerRoute(max);
          poolingmgr.setMaxTotal(2 * max);
      }
  }
if (maxConnTotal > 0) {
    poolingmgr.setMaxTotal(maxConnTotal);
}
if (maxConnPerRoute > 0) {
    poolingmgr.setDefaultMaxPerRoute(maxConnPerRoute);
}
@dsmiley
Copy link
Collaborator

dsmiley commented Oct 23, 2024

Maybe there's a documentation issue then. -1 was meant to be equivalent to "unspecified", not unlimited. Thus use whatever default that Apache HttpClient felt suitable. So it's working as intended.

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

2 participants