org.apache.http.ContentTooLongException: entity content is too long [158924648] for the configured buffer limit [104857600]

I'm facing the attached error while my service executing elastic search query.

this is the error log:

[ERROR] [ZScheduler-1] (Logs.scala:32) - Failed executing elasticSearch query
com.sksamuel.elastic4s.http.JavaClientExceptionWrapper: org.apache.http.ContentTooLongException: entity content is too long [158924647] for the configured buffer limit [104857600]
    at com.sksamuel.elastic4s.http.JavaClient$$anon$1.onFailure(JavaClient.scala:70)
    at org.elasticsearch.client.RestClient$FailureTrackingResponseListener.onDefinitiveFailure(RestClient.java:668)
    at org.elasticsearch.client.RestClient$1.failed(RestClient.java:417)
    at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:137)
    at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.executionFailed(DefaultClientExchangeHandlerImpl.java:101)
    at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.failed(AbstractClientExchangeHandler.java:426)
    at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.exception(HttpAsyncRequestExecutor.java:163)
    at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:276)
    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:114)
    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:591)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.apache.http.ContentTooLongException: entity content is too long [158924647] for the configured buffer limit [104857600]
    at org.elasticsearch.client.HeapBufferedAsyncResponseConsumer.onEntityEnclosed(HeapBufferedAsyncResponseConsumer.java:76)
    at org.apache.http.nio.protocol.AbstractAsyncResponseConsumer.responseReceived(AbstractAsyncResponseConsumer.java:137)
    at org.apache.http.impl.nio.client.MainClientExec.responseReceived(MainClientExec.java:315)
    at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseReceived(DefaultClientExchangeHandlerImpl.java:151)
    at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.responseReceived(HttpAsyncRequestExecutor.java:315)
    at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:255)
    ... 10 more

I tried to solve this using this solutiontext (HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory consumerFactory = new HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory(BUFFER_SIZE); ) But i get in trouble trying to fit that in the way the client implemented in my code, which is using the JavaClient apply implementation that already return JavaClient in it. which means i can't access the RestClient builder inside that function that does have access to the HeapBufferedResponseConsumerFactory.

I'm quite new to the elastic usage, and this is not my code, so i wish to make the little change possible, can someone help me solve this problem please.

This is the elastic client builder, which i wish to add the buffer parameter config in to:

  def createElasticClient(elasticUrl: String, credentials: Credentials): ElasticClient = {
    ElasticClient(
      JavaClient(
        ElasticProperties(elasticUrl),
        (requestConfigBuilder: RequestConfig.Builder) =>
          requestConfigBuilder
            .setSocketTimeout(INFINITE_SOCKET_TIMEOUT)
            .setConnectTimeout(CONNECTION_TIMEOUT),
        (httpClientBuilder: HttpAsyncClientBuilder) => {
          httpClientBuilder.setKeepAliveStrategy((_, _) => CONNECTION_KEEP_ALIVE_MS)
          httpClientBuilder.setDefaultCredentialsProvider(getCredentials(credentials))
        }
      )
    )
  }

Upvotes: 0

Views: 137

Answers (0)

Related Questions