I am new to writing the Client for ES , some how i was able to figure out to write basic client in java, can some one help me out how to pass credentials and self signed certificates
private static class RestHighLevelClientHelper {
private static final RestHighLevelClient CLIENT = new RestHighLevelClient(
RestClient.builder(
new HttpHost("localhost", 9200, "http"),
new HttpHost("localhost", 9201, "http")));
}
public static RestHighLevelClient getElasticSearchClientInstance() {
return RestHighLevelClientHelper.CLIENT;
}
Hi,
I have a similar issue connecting to elastic cloud. I followed the instructions how to set high-level client.
The problem i have is "Connection reset by peer". Could you help me with this issue? I tried to search online about how to connect to elastic cloud, but I failed to find any. Thank you.
Code below does work with regular ES node I installed on ami linux image.
Code:
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials("username", "password"));
Exception in thread "main" java.io.IOException: Connection reset by peer
at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:728)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:235)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:198)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:522)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:508)
at org.elasticsearch.client.IndicesClient.create(IndicesClient.java:99)
@Mingchih_Lin It would be better to open your own question as it's a different problem.
Will be easier for other users to find it IMO. Also, would be lovely if you format your code to make it nicer to read. (See https://discuss.elastic.co/c/elasticsearch)
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.