Endless Loop es 6.6.2

Can you help me???

    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>6.6.2</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>6.6.2</version>
    </dependency>
java.lang.RuntimeException: I/O reactor has been shut down
	at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:960)
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:229)
	at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1762)
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1732)
	at 
2019-04-24 21:25:03,879 ERROR [o.a.http.impl.nio.client.InternalHttpAsyncClient] - I/O reactor terminated abnormally
org.apache.http.nio.reactor.IOReactorException: I/O dispatch worker terminated abnormally
	at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:356)
	at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:194)
	at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.StackOverflowError: null
	at java.util.regex.Pattern$CharProperty.match(Pattern.java:3776)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4604)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4658)
	at java.util.regex.Pattern$Loop.match(Pattern.java:4785)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4717)
	at java.util.regex.Pattern$BranchConn.match(Pattern.java:4568)
	at java.util.regex.Pattern$CharProperty.match(Pattern.java:3777)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4604)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4658)
	at java.util.regex.Pattern$Loop.match(Pattern.java:4785)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4717)
	at java.util.regex.Pattern$BranchConn.match(Pattern.java:4568)
	at java.util.regex.Pattern$CharProperty.match(Pattern.java:3777)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4604)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4658)
	at java.util.regex.Pattern$Loop.match(Pattern.java:4785)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4717)
	at java.util.regex.Pattern$BranchConn.match(Pattern.java:4568)
	at java.util.regex.Pattern$CharProperty.match(Pattern.java:3777)
	at java.util.regex.Pattern$Branch.match(Pattern.java:4604)
	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4658)
	at java.util.regex.Pattern$Loop.match(Pattern.java:4785)
	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4717)
	at java.util.regex.Pattern$BranchConn.match(Pattern.java:4568)
	at java.util.regex.Pattern$CharProperty.match(Pattern.java:3777)

Hard to help without seeing any line of code.

java code

 SearchResponse response = null;
    try {
        log.info(searchRequest.source().toString());
        response = rhlClient.search(searchRequest,RequestOptions.DEFAULT);

    } catch (Exception e) {
        e.printStackTrace();
       log.error("链接==》es服务器异常====》");
    }
    SearchHits hits = response.getHits();
    log.info(JsonUtils.objectToJson(hits));

// use spring
@Autowired
private RestHighLevelClient rhlClient;

package com.dtk.goods.config;

import com.google.common.collect.Lists;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

import java.util.ArrayList;

@Configuration
@ComponentScan(basePackageClasses=ESClientFactory.class)
public class ESConfig {

@Value("${elasticSearch.host}")
private String hosts;

/*@Value("${elasticSearch.port}")
private int port;*/

@Value("${elasticSearch.client.connectNum}")
private Integer connectNum;

@Value("${elasticSearch.client.connectPerRoute}")
private Integer connectPerRoute;

@Bean
public ArrayList<HttpHost> httpHost(){
    //构造http强求端口号,进行解析处理
    ArrayList<HttpHost> hostList = Lists.newArrayList();
    String[] hostStrs = hosts.split(",");
    for (String host : hostStrs) {
        String[] hostPort=host.split(":");
        try {
            hostList.add(new HttpHost(hostPort[0], Integer.parseInt(hostPort[1]), "http"));
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }

    return hostList;
}

@Bean(initMethod="init",destroyMethod="close")
public ESClientFactory getFactory(){
    return ESClientFactory.
            build(httpHost(), connectNum, connectPerRoute);
}

@Bean(name = "restClient")
@Scope("singleton")
public RestClient getRestClient(){
    return getFactory().getClient();
}

@Bean(name = "restHighLevelClient")
@Scope("singleton")
public RestHighLevelClient getRHLClient(){
    return getFactory().getRhlClient();
}

}

package com.dtk.goods.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;
import java.util.List;

@Slf4j
public class ESClientFactory {

public static int CONNECT_TIMEOUT_MILLIS = 1000;
public static int SOCKET_TIMEOUT_MILLIS = 30000;
public static int CONNECTION_REQUEST_TIMEOUT_MILLIS = 500;
public static int MAX_CONN_PER_ROUTE = 10;
public static int MAX_CONN_TOTAL = 30;

private static List<HttpHost> HTTP_HOST;
private RestClientBuilder builder;
private RestClient restClient;
private RestHighLevelClient restHighLevelClient;

private static ESClientFactory esClientSpringFactory = new ESClientFactory();

private ESClientFactory() {
}

public static ESClientFactory build(List<HttpHost> httpHost,Integer maxConnectNum, Integer maxConnectPerRoute) {
    HTTP_HOST = httpHost;
    MAX_CONN_TOTAL = maxConnectNum;
    MAX_CONN_PER_ROUTE = maxConnectPerRoute;
    return esClientSpringFactory;
}

public static ESClientFactory build(List<HttpHost> httpHost, Integer connectTimeOut, Integer socketTimeOut,
                                          Integer connectionRequestTime, Integer maxConnectNum, Integer maxConnectPerRoute) {
    HTTP_HOST = httpHost;
    CONNECT_TIMEOUT_MILLIS = connectTimeOut;
    SOCKET_TIMEOUT_MILLIS = socketTimeOut;
    CONNECTION_REQUEST_TIMEOUT_MILLIS = connectionRequestTime;
    MAX_CONN_TOTAL = maxConnectNum;
    MAX_CONN_PER_ROUTE = maxConnectPerRoute;
    return esClientSpringFactory;
}


public void init() {
    builder = RestClient.builder(HTTP_HOST.toArray(new HttpHost[0]));
    setConnectTimeOutConfig();
    setMutiConnectConfig();
    restClient = builder.build();
    restHighLevelClient = new RestHighLevelClient(builder);
    log.info("init factory");
}
/**
 * 配置连接时间延时
 */
public void setConnectTimeOutConfig() {
    builder.setRequestConfigCallback(requestConfigBuilder -> {
        requestConfigBuilder.setConnectTimeout(CONNECT_TIMEOUT_MILLIS);
        requestConfigBuilder.setSocketTimeout(SOCKET_TIMEOUT_MILLIS);
        requestConfigBuilder.setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT_MILLIS);
        return requestConfigBuilder;
    });
}

/**
 * 使用异步httpclient时设置并发连接数
 */
public void setMutiConnectConfig() {
    builder.setHttpClientConfigCallback(httpClientBuilder -> {
        httpClientBuilder.setMaxConnTotal(MAX_CONN_TOTAL);
        httpClientBuilder.setMaxConnPerRoute(MAX_CONN_PER_ROUTE);
        return httpClientBuilder;
    });
}

public RestClient getClient() {
    return restClient;
}

public RestHighLevelClient getRhlClient() {
    return restHighLevelClient;
}

public void close() {

    if (restClient != null) {
        try {
            restClient.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    log.info("close client");
}

}

can you get it ...
many thread about 200 thread test,show this message...

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.

Could you also share the full stacktrace? I mean from which part of your code this error is thrown?

i will show info ....

i will show info ....

i will show info ....

From which part of your code this error is thrown?

here show timeout ......,the network is show well, the size is 100,and transport size min 150 kb

I removed your previous answer.

You have an elasticsearch cluster exposed directly on internet without any security.

You should NEVER EVER do that.

Please remove your elasticsearch cluster from internet or secure it.

Can you reproduce your described with a much simpler code? Something as simple as that:

public class App {
    public static void main(String[] args) {
        createData();
    }

    private static void createData() {
        try (RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(HttpHost.create("http://localhost:9200")))) {
            try {
                client.indices().delete(new DeleteIndexRequest("test"), RequestOptions.DEFAULT);
            } catch (ElasticsearchStatusException ignored) { }
            client.index(new IndexRequest("test").type("_doc").id("1").source("{\"foo\":\"bar\"}", XContentType.JSON), RequestOptions.DEFAULT);
            client.indices().refresh(new RefreshRequest("test"), RequestOptions.DEFAULT);
            SearchResponse response = client.search(new SearchRequest("test"), RequestOptions.DEFAULT);
            System.out.println("response.getHits().totalHits = " + response.getHits().totalHits);
        } catch (Exception e) {
            e.printStackTrace(System.err);
        }
    }
}

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