【异常】使用Elasticsearch的REST Client的An HTTP line is larger than 4096 bytes

问题描述:

在使用Elasticsearch的RestHightClient API 去搜索ES数据,当请求的参数过长的出现下面的异常:

{"type":"too_long_frame_exception","reason":"An HTTP line is larger than 4096 bytes."},默认情况下ES对请求参数设置为4K,如果遇到请求参数长度限制可以在elasticsearch.yml中修改如下参数:

http.max_initial_line_length: "8k"

http.max_header_size: "16k"


具体的参数配置链接:

https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html


ElasticsearchStatusException[Elasticsearch exception [type=too_long_frame_exception, reason=An HTTP line is larger than 4096 bytes.]]
	at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177)
	at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:526)
	at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:502)
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:409)
	at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:382)
	at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:323)
	at com.bbd.finance.commons.utils.ESSparkUtils.readBySingleField(ESSparkUtils.java:389)
	at com.bbd.finance.fc.functions.stream.FunctionForeachStreamCalcUpdate.readEsRelationCreateView(FunctionForeachStreamCalcUpdate.java:237)
	at com.bbd.finance.fc.functions.stream.FunctionForeachStreamCalcUpdate.call(FunctionForeachStreamCalcUpdate.java:180)
	at com.bbd.finance.fc.functions.stream.FunctionForeachStreamCalcUpdate.call(FunctionForeachStreamCalcUpdate.java:40)
	at org.apache.spark.streaming.api.java.JavaDStreamLike$$anonfun$foreachRDD$2.apply(JavaDStreamLike.scala:280)
	at org.apache.spark.streaming.api.java.JavaDStreamLike$$anonfun$foreachRDD$2.apply(JavaDStreamLike.scala:280)
	at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(ForEachDStream.scala:51)
	at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1$$anonfun$apply$mcV$sp$1.apply(ForEachDStream.scala:51)
	at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1$$anonfun$apply$mcV$sp$1.apply(ForEachDStream.scala:51)
	at org.apache.spark.streaming.dstream.DStream.createRDDWithLocalProperties(DStream.scala:416)
	at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1.apply$mcV$sp(ForEachDStream.scala:50)
	at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1.apply(ForEachDStream.scala:50)
	at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1.apply(ForEachDStream.scala:50)
	at scala.util.Try$.apply(Try.scala:192)
	at org.apache.spark.streaming.scheduler.Job.run(Job.scala:39)
	at org.apache.spark.streaming.scheduler.JobScheduler$JobHandler$$anonfun$run$1.apply$mcV$sp(JobScheduler.scala:257)
	at org.apache.spark.streaming.scheduler.JobScheduler$JobHandler$$anonfun$run$1.apply(JobScheduler.scala:257)
	at org.apache.spark.streaming.scheduler.JobScheduler$JobHandler$$anonfun$run$1.apply(JobScheduler.scala:257)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
	at org.apache.spark.streaming.scheduler.JobScheduler$JobHandler.run(JobScheduler.scala:256)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
	Suppressed: org.elasticsearch.client.ResponseException: GET http://ip:port/finance.off_line_relations/off_line_relations/_search?routing=dfa9e8ad7bf4a60a5adf927545127768%2C803ac148a0724824aba01544613bb68e%2Ca43e124fec414174b4a4a0d1e0c1b2c2%2C6468c35044e84627b7363817e6e5f0e9%2Ce2f6de2ebd134ddeb4d44c5db7025bfc%2C75b96e53948a48c4ab2409374c79df35%2C07cd02cee8564531bf2a6cc109784984%2C7282ce28c9564ca98cb7ac3b1fea577d%2C1969b2fc43724096a17110fe511c2671%2C26ed66b0b10043febf63a179429c8a6b%2C1865c92b58b244b7a5441eb3240ba36d%2C272636326acd4ae283aa264b103aab8b%2C646895caeaf44adfbc938b9d455db149%2C33643c1e6f7f468f8a44158f865db55a%2C4eec258b469c41e0af26d9467664798b%2Ce8c1205d09d14d648bd89670a1e0a39e%2Ce0811139ef6d4a4d8e3ca1b2b5b00e87%2C03e5f15f2b09423486676c7040a036be%2Cd82ec128d9ea41b99636532951e1602a%2Cb6f2f8a63e224b50a5ce5c6e2fd3aac9%2C887873e1c3ad4fd48e173ba35db4c3db%2C945050fcfed0a7326cd14843d6c78944%2C6b1907e96e5441d3b590ff2a4bf78050%2Ce05672e9dafa49f88399a9ee742b3ea0%2C7a08ad4ac3cc4d0691506b8fb580efb7%2Ce531faf0fc514d42b2ab626a1dea1035%2C444a1bf4487e4857881e2142ee4acedf%2C6c0d4fb9b7c74f20af9ad268739ce941%2C1386226f1a5147d098c554b0948e4c80%2Cd06a85135a5846579cb311bb5c4e55b4%2C412b985f2f4a4de19e66edd123d9045f%2Cd8b5237f02f7442eaaffc19be847ae84%2Cd128b18a2cb74fe5a3c8bdb165941d25%2C529b4a8941114928bbe60adb169c7bb5%2C1c91417dc29541c498cc00d3a7bf6432%2C623d5751185f4996a5690f8701d162b3%2Cba146ca2b5a247e6be847822fd3bf38f%2Cf711c044598a48839fe137f8293ead6a%2Ce71b2fe0053a48efa261487637c33f06%2Cba0ad087dc824060b6e321d82976471f%2C0f68f05cb5cf4fe2aeca6c79c1368745%2Cc827543135bd421498d59be53efede18%2C6d7d3a7b0d934e539101349d915ea619%2C89fd3fb4bdca4b8e978b47ac7e999866%2C7b4676870e1d469b9425faf8e8719089%2C87ae627b8c384924b98536b6b7112d42%2C82f2f33126494d23b4a7c4c83e904aa4%2C05c3d3188203478481d9f4b7f29abf51%2C52f165ab21804464a12841d7b6de5131%2Cf32e7c3be95656c024d746c108414075%2Cc102d27e5ada45809f9c7a6e3e534575%2C7778b8fadfa944d7ab56ff14d009658b%2C5e19c09fe1744960b496fdca0d0d0f2e%2C5c0b9edfa688420d99b57034f910a2a6%2C0ac92bc6653443bc8b9cf1cb83901b47%2C7de9ec149f4745b0b135351fdaf97629%2C22d24b60fb6a4e408b1dc0521d0b68f8%2C7ebd9c505ab1476ca7f2283d405d7e7f%2C51533d39f3d9400ba75092b9d4c7f76b%2C50ee95e046f9411faf712dc3b3c6ba93%2C50b5eb60a9c04d81b9e714393837a657%2C8686d41991c14ef38b6e46a965b8da33%2Cc5ab36d7336045ceb9027e53f5b4115d%2Cf01ee1b2777f4a068cf9d68f85b5ce23%2C79179eaf92204e76bc8890d1fd98d674%2Cb0cf683d01884e2092297871b2dec331%2C230cb2a8f6044e1abe776a1c3c2722d7%2C1cba6b5866ec405f972e0aab3fc21120%2Cdc10c75df2d548ab93a6a8908d8e4d24%2C003a652e9000f533f5c427922eb81e21%2C60a4b4c4591b4502acf58e5d584edf2c%2C91936f76c3b145659fef12364f746850%2C38cd0eeb36644d2ba22752ba77e8e106%2Cd698f6b12a2f43b99a091aba76cdfb9d%2Cc369fdd9724449688016e8f4681e58e2%2C835b529794b4450e94fa5811e54af599%2Cf0116ff4361540a8b69168752be66d5c%2Cbb1fe5f85aa64aa28ada468e07c1e456%2C2c4797666d1547b197a483541a889983%2C5d7f794366374f8ca2d64fd36060165c%2Cb742fb2136f648afb7aa7f43551fd5ca%2Cbd59c39c0e9e41ababa8b9b5b4287ad1%2C5b3e138bb9fa4df49917a375f4702e82%2Ce3c100a51f8e467d9e4ea45b711a6d1e%2C6e7b96646e464b6b80491c8f0c4a48d7%2Ca182b74a6905415bab4eb8cb1497c4d0%2C4b7c28a76f0e4baa9c96cd8be42c5aec%2C26a2eb0d22504722bafe775f213f8104%2Cf01857091f98432f89e28fcf9066a801%2Cd7503f4db21b451b990a1c7215ad02ff%2Ce2442d1d25d14187b64938674ea68f70%2C6eacb393d2b94bf0a2f73f6974e2e313%2Cb553e53169ce4d22baa985930522e4dd%2C91d8454b3b814cc0a869ecf2dfed7d2a%2C50a78ce1270bffb02f38ed71cdf6a7ad%2C1f5740035a3f4afd938e7ecf665585ae%2C5b02acd4e1f24012b2973f4c34d4d745%2Cdc4b89420fc8487d8a7242dc297ee2f5%2C1ad48c535ede438f98bd440f48239d72%2C03df3b7ec16944aa810417cffe2dc62e%2C4eb703c35fb44f76bc06fc17deb88794%2C76d3bb19c2594a2b92877a8921f601d0%2C9f79f65ce2a14cb4865061c72cb13d1a%2C0366f9453fda497b99e2db8202e21f01%2Cc1bf0131a4304c1fa67591ad59aec912%2C5d000f1fbdd64811b4ace86b6d8b8d2f%2C6a99a086b43c443f8e73cdbda3fa0394%2C28e6af35ec0b43958ba925947be3b313%2Cac203e6fd9174c4e964ad71d84d5ea08%2C51244f42abd3413db302748e772362d4%2Ccdf5c915c4c14d59a4fe62958cefe13d%2C54278ba034c643d7a72b75da7253f9c0%2Cad516a8b4bf14e80a779ef00aa6efbb9%2Cd1a9aaab7da74194aa3a6e36a2609e68%2Cb72be6dbd62a4c679b6dd38cba813c16%2Ca66435f4a3a44a8b9d7b5bd45a548428%2C9d3d6bdcf7f34adc9ce93f8c569a6cf0%2C8580961d632e4df2a51e2dca40d16340%2C20bff77e32724651a35ef51cb6d99f5a%2Cb27694db3f7c4183b5e96a8021f8220f%2C8fe39c4061f3467f80577033b920b73d%2C480d624b2c2a41a3aeca6f6dbd3bcaba%2C0f5eded9769d484d9e420d442e952299%2C2457e1473eb5410aa5d33b94913bdbc9%2C4201e78e81774b72873a051bb90a566d%2C36acfb9800aa4ddfba95005b4a2b43b4%2C2e13e84f555648c7a23f829cb5e7f72f%2C6ead25ce42b94168889d8999d3158fd5%2C40ccea616a174560a8170f7a7fffb3d0%2C345bfc21c060423c9c3fe0df59bfbdae%2C28853dc1f96341949df338f73e2dffe6%2C4f338915bd3d40d19584e00135f4c672%2C67aed59fed874be2bdd8862fc192c186&typed_keys=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&search_type=query_then_fetch&batched_reduce_size=512: HTTP/1.0 400 Bad Request
{"error":{"root_cause":[{"type":"too_long_frame_exception","reason":"An HTTP line is larger than 4096 bytes."}],"type":"too_long_frame_exception","reason":"An HTTP line is larger than 4096 bytes."},"status":400}
		at org.elasticsearch.client.RestClient$1.completed(RestClient.java:354)
		at org.elasticsearch.client.RestClient$1.completed(RestClient.java:343)
		at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:119)
		at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:181)
		at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:436)
		at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:326)
		at org.apache.http.impl.nio.client.InternalRequestExecutor.inputReady(InternalRequestExecutor.java:83)
		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: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:588)
		... 1 more


你可能感兴趣的:(elasticsearch)