I am using low level rest API to access Elastic Search in AWS (AWS Service). Aws provides the HTTPS url.
@Bean
public RestClient restClient() throws Exception {
RestClient restClient = RestClient.builder(new HttpHost(esHost, esPort))
.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(5000)
.setSocketTimeout(60000))
.setMaxRetryTimeoutMillis(60000)
.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
HttpAsyncClientBuilder httpAsyncClientBuilder = null;
try {
httpAsyncClientBuilder = httpClientBuilder.setSSLContext(SSLContext.getDefault());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return httpAsyncClientBuilder;
}
})
.build();
return restClient;
}
I am not able to get RestClient over SSL connection.
Following are the error messages:
2017-07-31 09:22:43.001 INFO 6239 --- [/O dispatcher 1] com.example.configurations.EsConfig : java.io.IOException: Connection reset by peer
2017-07-31 09:22:43.018 INFO 6239 --- [/O dispatcher 2] com.example.configurations.EsConfig : java.io.IOException: Connection reset by peer
2017-07-31 09:22:43.037 INFO 6239 --- [/O dispatcher 3] com.example.configurations.EsConfig : org.apache.http.ConnectionClosedException: Connection closed
2017-07-31 09:22:43.043 INFO 6239 --- [/O dispatcher 4] com.example.configurations.EsConfig : java.io.IOException: Connection reset by peer
2017-07-31 09:22:43.075 INFO 6239 --- [/O dispatcher 6] com.example.configurations.EsConfig : java.io.IOException: Connection reset by peer
2017-07-31 09:22:43.075 INFO 6239 --- [/O dispatcher 5] com.example.configurations.EsConfig : java.io.IOException: Connection reset by peer
2017-07-31 09:22:43.075 INFO 6239 --- [/O dispatcher 7] com.example.configurations.EsConfig : java.io.IOException: Connection reset by peer
2017-07-31 09:22:43.077 INFO 6239 --- [/O dispatcher 8] com.example.configurations.EsConfig : org.apache.http.ConnectionClosedException: Connection closed
2017-07-31 09:22:43.099 INFO 6239 --- [/O dispatcher 2] com.example.configurations.EsConfig : java.io.IOException: Connection reset by peer
Please suggest me what is needed to get a RestClient over SSL connection.
Thanks