来自AWS托pipeElasticsearch的偶尔“未能回应”

我们有一个托pipe在Amazon Elasticsearch Service(AWS)上的Elasticsearch集群。

我们为ElasticSearch使用Jest Java HTTP Rest客户端 。

每隔一段时间(可能是1万个请求中的1个),它似乎会在没有响应的情况下closures连接。

我们的应用程序中的堆栈跟踪如下所示:

ERROR [2016-04-11 09:18:43,497] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: b9b9ee1e4eefadd2 ! org.apache.http.NoHttpResponseException: search-xxx.eu-west-1.es.amazonaws.com:443 failed to respond ! at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:143) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) ~[my-app-0.0.1.jar:0.0.1] ! at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107) ~[my-app-0.0.1.jar:0.0.1] ! at io.searchbox.client.http.JestHttpClient.execute(JestHttpClient.java:48) ~[my-app-0.0.1.jar:0.0.1] 

来自“ org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead ”的相关代码如下所示:

 final int i = sessionBuffer.readLine(this.lineBuf); if (i == -1 && count == 0) { // The server just dropped connection on us throw new NoHttpResponseException("The target server failed to respond"); } 

据我所知,亚马逊并不允许我访问Elasticsearch服务器的日志。

所以:

  1. 我怎样才能诊断和修复这个错误的原因?
  2. 如果最好的解决办法是我的应用程序重试这些失败,是否有一个简单的方法来重试使用JEST? 我没有看到任何configuration选项自动执行此操作。

TIA

1 :(还不知道)

2:您可以configurationJest重试Elasticsearch操作失败,出现networking错误,如:

 new JestClientFactory() { @Override protected HttpClientBuilder configureHttpClient(HttpClientBuilder builder) { builder = super.configureHttpClient(builder); // See DefaultHttpRequestRetryHandler.requestSentRetryEnabled // // true if it's OK to retry non-idempotent requests that have been sent // and then fail with network issues (not HTTP failures). // // "true" here will retry POST requests which have been sent but where // the response was not received. This arguably is a bit risky. // // Retries are logged at INFO level to org.apache.http.impl.execchain.RetryExec boolean requestSentRetryEnabled = true; builder.setRetryHandler(new DefaultHttpRequestRetryHandler( 3, requestSentRetryEnabled)); return builder; } }