lengthDelimitedCoder导致org.apache.http.connectionclosedexception:内容长度分隔的消息正文过早结束

inkz8wg9  于 2021-06-13  发布在  ElasticSearch
关注(0)|答案(0)|浏览(475)

我正在尝试使用resthighlevelclient从elasticsearch进行搜索,如下所示:

RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder()
builder.setHttpAsyncResponseConsumerFactory(new HttpAsyncResponseConsumerFactory
        .HeapBufferedResponseConsumerFactory(BUFFER_LIMIT))
SearchResponse searchResponse = client.search(searchRequest, builder.build())
return searchResponse

但对于某些搜索,我不断遇到这种过早的内容长度结束错误消息,我不知道为什么:

org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 405065025; received: 340164608
    at org.apache.http.impl.nio.codecs.LengthDelimitedDecoder.read(LengthDelimitedDecoder.java:89)
    at org.apache.http.nio.util.SimpleInputBuffer.consumeContent(SimpleInputBuffer.java:66)
    at org.elasticsearch.client.HeapBufferedAsyncResponseConsumer.onContentReceived(HeapBufferedAsyncResponseConsumer.java:96)
    at org.apache.http.nio.protocol.AbstractAsyncResponseConsumer.consumeContent(AbstractAsyncResponseConsumer.java:141)
    at org.apache.http.impl.nio.client.MainClientExec.consumeContent(MainClientExec.java:329)
    at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.consumeContent(DefaultClientExchangeHandlerImpl.java:153)
    at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:324)
    at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:265)
    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)
    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)
    at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:121)
    at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
    at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
    at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588)
    at java.lang.Thread.run(Thread.java:748)

我已经研究过其他“以内容长度分隔的消息体过早结束”的问题,但似乎无法解决这个问题,因为这个问题直接嵌入到elasticsearch中。
为什么会这样?什么会导致它过早结束?有什么办法?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题