RestHighLevelClient 异常java.io.IOException: 远程主机强迫关闭了一个现有的连接的解决办法
RestHighLevelClient 连接相关说明，在特定场景如超时等会关闭连接。相关elasticsearch连接介绍https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-getting-started-initialization.html保持连接不关闭的方法RestClientBuilder builder = RestClient.builder... builder.setHttpClientConfigCallback(httpClientBuilder -> {//核心代码 保活连接 httpClientBuilder.setKeepAliveStrategy((response, context) -> Duration.ofMinutes(3).toMillis()); httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);//安全认证 return httpClientBuilder;});这样再等待几分钟甚至更长时间后，再次查询就不会出现上方错误