-
Notifications
You must be signed in to change notification settings - Fork 284
Open
Description
Java API client version
8.15.3
Java version
jdk8
Elasticsearch Version
8.17.3
Problem description
When using Elasticsearch Java Client 8.x, the configured timeout parameters (connectTimeout, connectionRequestTimeout, socketTimeout) do not appear to be effective. Despite setting all timeouts to 100ms, I am observing requests that take over 3500ms to complete.
public static ElasticsearchClient elasticsearchClient() {
RestClient restClient = RestClient.builder(HttpHost.create("XXX"))
.setRequestConfigCallback(builder -> {
builder.setConnectTimeout(100);
builder.setSocketTimeout(100);
builder.setConnectionRequestTimeout(100);
return builder;
})
.setHttpClientConfigCallback(httpClientBuilder -> {
org.apache.http.client.CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
UsernamePasswordCredentials usernamePasswordCredentials = new UsernamePasswordCredentials("XXX", "XXX");
credentialsProvider.setCredentials(AuthScope.ANY, usernamePasswordCredentials);
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
httpClientBuilder.setMaxConnTotal(200);
httpClientBuilder.setMaxConnPerRoute(100);
return httpClientBuilder;
}).setCompressionEnabled(true).build();
RestClientTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
return new ElasticsearchClient(transport);
}
ElasticsearchClient esClient = elasticsearchClient();
esClient.search(searchRequest, XXX.class);
When connection, request, or socket operations exceed the configured 100ms, timeout exceptions should be thrown immediately. Requests should not persist for 3500ms or longer.
Metadata
Metadata
Assignees
Labels
No labels