Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure read timeout OpenSearch client

I don't find in documentation how to configure read timeout on an OpenSearch RestHighLevelClient:

final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
            credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
            RestClientBuilder builder = RestClient.builder(
                            new HttpHost(url, port, scheme))
                    .setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
                            .setDefaultCredentialsProvider(credentialsProvider));
            return new RestHighLevelClient(builder);
like image 406
Inconvenient9 Avatar asked Jun 17 '26 01:06

Inconvenient9


1 Answers

I found a solution:

.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setSocketTimeout(10000))
like image 184
Inconvenient9 Avatar answered Jun 19 '26 15:06

Inconvenient9



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!