# 오류
elasticsearch 6.8 설치버전에 연동하기 위해 elasticsearch-rest-high-level-client 라이브러리 6.8.0 버전을 사용했다.
클라이언트 생성하고 client.search(SearchRequest) 메소드 호출하는 과정에서 connection closed 에러가 발생한다.
org.apache.http.ConnectionClosedException: Connection closed at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.endOfInput(HttpAsyncRequestExecutor.java:341) at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:263) 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:116) at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:164) at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:339) at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:317) at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:278) at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:106) at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:590) at java.lang.Thread.run(Thread.java:745)
# 원인
기존에 transport 6.0 라이브러리를 사용할 때는 9300 포트를 사용했는데 elasticsearch-rest-high-level-client 라이브러리는 9200 포트를 사용해야 한다고 한다. (rest 요청은 그래야한다고 함)
# 해결
The problem was the port was wrong. For REST requests the port should be 9200 (and not 9300 like it was configured). More info on elasticsearch ports.
I wish elasticsearch could make a more explicit error log or a hint like "are you connecting with the right port?" for when one tries to access the 9300 port with anything other than the built-in clients.
※ 참고
stackoverflow.com/a/42364578/1838578