ElasticSearch-RestHighLevelClient-等待[30000]毫秒之后的侦听器超时

时间:2018-07-14 17:31:40

标签: java elasticsearch elastic-stack

在索引100k的文档时,以下行的listener超时异常

IndexResponse response = SearchEngineClient.getInstance2().index(request);

请找到完整的堆栈跟踪

Exception in thread "main" java.io.IOException: listener timeout after waiting f
or [30000] ms
        at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClie
nt.java:663)
        at org.elasticsearch.client.RestClient.performRequest(RestClient.java:22
2)
        at org.elasticsearch.client.RestClient.performRequest(RestClient.java:19
4)
        at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighL
evelClient.java:443)
        at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEn
tity(RestHighLevelClient.java:429)
        at org.elasticsearch.client.RestHighLevelClient.index(RestHighLevelClien
t.java:312)
        at com.es.utility.DocumentIndex.main(DocumentIndex.java:255)

1 个答案:

答案 0 :(得分:1)

尝试一下,它可以和我一起使用

RestClientBuilder builder = RestClient.builder(
                new HttpHost(HOST, PORT))
                .setRequestConfigCallback(
                    new RestClientBuilder.RequestConfigCallback() {
                        @Override
                        public RequestConfig.Builder customizeRequestConfig(
                                RequestConfig.Builder requestConfigBuilder) {
                            return requestConfigBuilder
                                .setConnectTimeout(5000)
                                .setSocketTimeout(60000);
                        }
                    }).setMaxRetryTimeoutMillis(60000);