# EsHadoopInvalidRequest: An HTTP line is larger than 4096 bytes

**URL:** <https://discuss.elastic.co/t/eshadoopinvalidrequest-an-http-line-is-larger-than-4096-bytes/136572>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [June 19, 2018, 8:50pm UTC](https://discuss.elastic.co/t/eshadoopinvalidrequest-an-http-line-is-larger-than-4096-bytes/136572 "2018-06-19T20:50:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoramd](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yoramd](https://discuss.elastic.co/u/yoramd)\
**Post date:** [June 19, 2018, 8:50pm UTC](https://discuss.elastic.co/t/eshadoopinvalidrequest-an-http-line-is-larger-than-4096-bytes/136572/1 "2018-06-19T20:50:31Z")

</div>

Hi  
We're trying to use spark-elasticsearch to load data from an Elasticsearch index into Spark for processing.

We load the data using:

```
sparkSession
      .read
      .format("es")
      .option("pushdown", "false")
      .option("es.nodes", nodesUrl)
      .option("es.port", "9200")
      .load(indexName)

```

When running we get the following error:

```
org.elasticsearch.hadoop.rest.EsHadoopInvalidRequest: An HTTP line is larger than 4096 bytes.
{"query":{"match_all":{}}}
    at org.elasticsearch.hadoop.rest.RestClient.checkResponse(RestClient.java:505)
    at org.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:463)
    at org.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:445)
    at org.elasticsearch.hadoop.rest.RestRepository.scroll(RestRepository.java:365)
    at org.elasticsearch.hadoop.rest.ScrollQuery.hasNext(ScrollQuery.java:92)
    at org.elasticsearch.spark.rdd.AbstractEsRDDIterator.hasNext(AbstractEsRDDIterator.scala:61)
    at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
    at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
    at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
    at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
    at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
    at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
    at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:461)
    at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
    at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:408)
    at org.apache.spark.util.random.SamplingUtils$.reservoirSampleAndCount(SamplingUtils.scala:41)
    at org.apache.spark.RangePartitioner$$anonfun$9.apply(Partitioner.scala:263)
    at org.apache.spark.RangePartitioner$$anonfun$9.apply(Partitioner.scala:261)
    at org.apache.spark.rdd.RDD$$anonfun$mapPartitionsWithIndex$1$$anonfun$apply$26.apply(RDD.scala:844)
    at org.apache.spark.rdd.RDD$$anonfun$mapPartitionsWithIndex$1$$anonfun$apply$26.apply(RDD.scala:844)
    at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:38)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:323)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:287)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
    at org.apache.spark.scheduler.Task.run(Task.scala:108)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:338)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

```

We tried to debug it and realized that the request URL sent to Elasticsearch includes the "\_source" parameter as a URL parameter and not put inside the body of the request.

The documents in the index we're reading have 350 fields, which is probably the reason for why the URL is so long.

Is there any way of overcoming this error?  
Are we doing something wrong here?

Thanks

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [June 21, 2018, 5:30pm UTC](https://discuss.elastic.co/t/eshadoopinvalidrequest-an-http-line-is-larger-than-4096-bytes/136572/2 "2018-06-21T17:30:08Z")

</div>

This is a known issue. There should be a fix landing soon: [https://github.com/elastic/elasticsearch-hadoop/pull/1154](https://github.com/elastic/elasticsearch-hadoop/pull/1154)

---

<div class="post-metadata">

**Author:** ![yoramd](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yoramd](https://discuss.elastic.co/u/yoramd)\
**Post date:** [June 22, 2018, 12:58am UTC](https://discuss.elastic.co/t/eshadoopinvalidrequest-an-http-line-is-larger-than-4096-bytes/136572/3 "2018-06-22T00:58:29Z")

</div>

Thanks James!

---

<div class="post-metadata">

**Author:** ![jamesjin](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@jamesjin](https://discuss.elastic.co/u/jamesjin)\
**Post date:** [July 19, 2018, 3:15pm UTC](https://discuss.elastic.co/t/eshadoopinvalidrequest-an-http-line-is-larger-than-4096-bytes/136572/4 "2018-07-19T15:15:48Z")

</div>

Hi @james.baiera

I have the similar issue, how can fix it? thank you

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [July 25, 2018, 2:51pm UTC](https://discuss.elastic.co/t/eshadoopinvalidrequest-an-http-line-is-larger-than-4096-bytes/136572/5 "2018-07-25T14:51:16Z")

</div>

@jamesjin the fix should be applied now. Please check out the newly released 6.3.2 to pull the change in.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 22, 2018, 2:51pm UTC](https://discuss.elastic.co/t/eshadoopinvalidrequest-an-http-line-is-larger-than-4096-bytes/136572/6 "2018-08-22T14:51:20Z")

</div>

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