Hi guys, I am using docker-java to implement my business, I love this library and I found I cannot cusomize ApacheDockerHttpClient' HttpClient request configs.
I am initializing ApacheDockerHttpClient instance with this code:
return new ApacheDockerHttpClient.Builder()
.dockerHost(dockerClientConfig.getDockerHost())
.sslConfig(dockerClientConfig.getSSLConfig())
.build();
I have view the source code, and may be you guys can change the ApacheDockerHttpClientImpl scope to support caller change httpClient properties?
Just return HttpClientBuilder instead HttpClient will be more flexiable
httpClient = HttpClients.custom()
.setRequestExecutor(new HijackingHttpRequestExecutor(null))
.setConnectionManager(new PoolingHttpClientConnectionManager(
socketFactoryRegistry,
new ManagedHttpClientConnectionFactory(
null,
null,
null,
null,
message -> {
Header transferEncodingHeader = message.getFirstHeader(HttpHeaders.TRANSFER_ENCODING);
if (transferEncodingHeader != null) {
if ("identity".equalsIgnoreCase(transferEncodingHeader.getValue())) {
return ContentLengthStrategy.UNDEFINED;
}
}
return DefaultContentLengthStrategy.INSTANCE.determineLength(message);
},
null
)
))
.build();
Thanks
I am using docker-java with latest version 3.2.5
Hi @richard-yao,
Could you please describe which properties you want to customize? Is there anything that does not work for you with the default ones?
Hi @bsideup
Thanks for your answer.
I want to change the default max connections per route property in PoolingHttpClientConnectionManager class, I have used httpclient in other business service, I noticed that in PoolingHttpClientConnectionManager source code
public static final int DEFAULT_MAX_TOTAL_CONNECTIONS = 25;
public static final int DEFAULT_MAX_CONNECTIONS_PER_ROUTE = 5;
I want customize these parameters to fit different machine's performance.
And the HttpClients.custom().build() method using default RequestConfig with these parameters:
private static final Timeout DEFAULT_CONNECTION_REQUEST_TIMEOUT = Timeout.ofMinutes(3);
private static final Timeout DEFAULT_CONNECT_TIMEOUT = Timeout.ofMinutes(3);
private static final TimeValue DEFAULT_CONN_KEEP_ALIVE = TimeValue.ofMinutes(3);
The default timeout for my business is not very suitable, I want to decrease the connectTimeout
I have a same issue.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
why closed?
Most helpful comment
Hi @bsideup
Thanks for your answer.
I want to change the default max connections per route property in PoolingHttpClientConnectionManager class, I have used httpclient in other business service, I noticed that in PoolingHttpClientConnectionManager source code
I want customize these parameters to fit different machine's performance.
And the
HttpClients.custom().build()method using default RequestConfig with these parameters:The default timeout for my business is not very suitable, I want to decrease the connectTimeout