# How to set listener timeout by high level rest client?

**URL:** https://discuss.elastic.co/t/how-to-set-listener-timeout-by-high-level-rest-client/125051
**Category:** Elasticsearch
**Created:** [March 21, 2018, 5:40pm UTC](https://discuss.elastic.co/t/how-to-set-listener-timeout-by-high-level-rest-client/125051 "2018-03-21T17:40:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![majid\_zarrin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/majid_zarrin/32/29103_2.png) [@majid\_zarrin](https://discuss.elastic.co/u/majid_zarrin)
#### Post date: [March 21, 2018, 5:40pm UTC](https://discuss.elastic.co/t/how-to-set-listener-timeout-by-high-level-rest-client/125051/1 "2018-03-21T17:40:51Z")

</div>

Hello guys  
based on the [our previous problem](https://discuss.elastic.co/t/how-to-use-search-after-with-match-all-query-and-without-sorting/124179/2) I need read all documents in an Index with sorting. as it's data is somewhat big I confront with the search timeout.  
here is the simplified code:

```
    RestHighLevelClient highLevelClient = new RestHighLevelClient(
            RestClient.builder(
                    new HttpHost("host1", port1, "http"),
                    new HttpHost("host2", port2, "http"))
    );
    // create SearchSourceBuilder
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
    searchSourceBuilder.query(QueryBuilders.matchAllQuery());
    searchSourceBuilder.size(5000);
    searchSourceBuilder.sort(new FieldSortBuilder("_uid").order(SortOrder.ASC));
    searchSourceBuilder.timeout(new TimeValue(10, TimeUnit.MINUTES));
    // create SearchRequest
    SearchRequest searchRequest = new SearchRequest("telemine");
    searchRequest.types("messages");
    searchRequest.source(searchSourceBuilder);
    searchRequest.scroll(new TimeValue(10, TimeUnit.MINUTES));
    // execute Search
    SearchResponse searchResponse = highLevelClient.search(searchRequest);

```

and here is the error

```
java.io.IOException: listener timeout after waiting for [30000] ms
at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:663)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:222)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:194)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:443)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:429)
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:368)

```

I think sorting on 1.4 billions of data is time-consuming.  
I'll be appreciated if someone could help to set listener timeout.  
thanks

---

<div class="post-metadata">

### Author: ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)
#### Post date: [March 23, 2018, 9:31am UTC](https://discuss.elastic.co/t/how-to-set-listener-timeout-by-high-level-rest-client/125051/2 "2018-03-23T09:31:38Z")

</div>

Hi,  
you need to increase the maxRetryTimeout and the socket timeout when you initialize the low-level REST client, see [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/\_timeouts.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_timeouts.html) .

Cheers  
Luca

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 20, 2018, 9:31am UTC](https://discuss.elastic.co/t/how-to-set-listener-timeout-by-high-level-rest-client/125051/3 "2018-04-20T09:31:58Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
