Skip to content

Rest client settings related to connections and keep alives are broken #27827

@Tim-Brooks

Description

@Tim-Brooks

In 5.6 we introduced a change to the rest client that told the apache client to use system properties for some settings (3e4bc02).

HttpAsyncClientBuilder httpClientBuilder = HttpAsyncClientBuilder.create().setDefaultRequestConfig(requestConfigBuilder.build())
                //default settings for connection pooling may be too constraining
                .setMaxConnPerRoute(DEFAULT_MAX_CONN_PER_ROUTE).setMaxConnTotal(DEFAULT_MAX_CONN_TOTAL).useSystemProperties();

This was introduced to force the client to use the system default SSLContext. Unfortunately this also leads the http client to use system properties for max connections, keep alive, and other configs. This means that our settings of DEFAULT_MAX_CONN_PER_ROUTE and DEFAULT_MAX_CONN_TOTAL are ignored. Additionally any settings that a user changes related to the client might be ignored (depending on the setting).

org.apache.http.impl.nio.client.HttpAsyncClientBuilder.class

            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);
                }
            } else {
                if (maxConnTotal > 0) {
                    poolingmgr.setMaxTotal(maxConnTotal);
                }
                if (maxConnPerRoute > 0) {
                    poolingmgr.setDefaultMaxPerRoute(maxConnPerRoute);
                }
            }

I think we need to configured the SSLContext specifically, opposed for forcing system properties for many settings.

@jaymode

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions