Elasticsearch client defaulting to http

We hosted our elasticsearch cluster in AWS. We do not have port number exposed to the clients using elastic datastore. Whenever we instantiate the RestClient using the hostname, the client is defaulting to 'HTTP' rather than 'HTTPs'.

Our host is exposed to Https.

public RestClient getClient() throws Exception 
{
   return RestClient.builder(new HttpHost(_hostName)).build();
}

Please find the logs for more details.

2018-03-06 20:20:48 DEBUG InternalIODispatch:85 - http-outgoing-0 [ACTIVE] [content length: 94; pos: 94; completed: true]
org.elasticsearch.client.ResponseException: method [PUT], host [http://ge3jo3ij4fkxjoe334q65j3tna.us-east-2.es.amazonaws.com], URI [/diagnostics/inv/diatest2], status line [HTTP/1.1 403 Forbidden]
{"Message":"User: anonymous is not authorized to perform: es:ESHttpPut on resource: sdsessec"}
2018-03-06 20:20:48 ERROR ElasticSearchDAO:36 - ElasticSearchContext : es_index: /diagnostics/inv/ ------> method [PUT], host [http://ge3jo3ij4fkxjoe334q65j3tna.us-east-2.es.amazonaws.com], URI [/diagnostics/inv/diatest2], status line [HTTP/1.1 403 Forbidden]
{"Message":"User: anonymous is not authorized to perform: es:ESHttpPut on resource: sdsessec"}
2018-03-06 20:20:48 DEBUG PoolingNHttpClientConnectionManager:203 - Connection manager is shutting down
2018-03-06 20:20:48 DEBUG ManagedNHttpClientConnectionImpl:123 - http-outgoing-0 [ACTIVE][r:r]: Close
at org.elasticsearch.client.RestClient$1.completed(RestClient.java:355)
at org.elasticsearch.client.RestClient$1.completed(RestClient.java:344)
at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:119)
at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:177)
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)
at java.lang.Thread.run(Unknown Source)
2018-03-06 20:20:48 DEBUG InternalIODispatch:62 - http-outgoing-0 [CLOSED]: Disconnected
2018-03-06 20:20:48 DEBUG PoolingNHttpClientConnectionManager:205 - Connection manager shut down

Is this the behavior of the RestClient or am I missing something here? Please help.

My guess is that you are missing some authentification here.

BTW did you look at cloud.elastic.co and https://aws.amazon.com/marketplace/pp/B01N6YCISK ?

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