Configuring requests timeouts can be done by providing an instance of RequestConfigCallback while building the RestClient through its builder. The interface has one method that receives an instance of org.apache.http.client.config.RequestConfig.Builder as an argument and has the same return type. The request config builder can be modified and then returned. In the following example we increase the connect timeout (defaults to 1 second) and the socket timeout (defaults to 30 seconds).

RestClientBuilder builder = RestClient.builder(
    new HttpHost("localhost", 9200))
        new RestClientBuilder.RequestConfigCallback() {
            public RequestConfig.Builder customizeRequestConfig(
                    RequestConfig.Builder requestConfigBuilder) {
                return requestConfigBuilder

Timeouts also can be set per request with RequestOptions, which overrides RestClient customizeRequestConfig.

RequestConfig requestConfig = RequestConfig.custom()
RequestOptions options = RequestOptions.DEFAULT.toBuilder()