i am trying to invoke rest call and have below rest high level client.
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials("elastic", "cool"));
client = new RestHighLevelClient(RestClient.builder(new HttpHost(HOST, PORT, SCHEMA))
.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
}));
i have host and port defined in application.properties file as below
#test/dev host elastic service url
HOST.URL=http://go-test
#test/dev host port
HOST.PORT=9200
SCHEMA=http
My bean property
@Value("${HOST.URL}")
private String HOST;
@Value("${HOST.PORT}")
private int PORT;
@Value("${SCHEMA}")
private String SCHEMA;
when i try to run i am getting below execption...
Caused by: java.net.UnknownHostException: http://go-test
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302)
at java.net.InetAddress.getAllByName0(InetAddress.java:1255)
at java.net.InetAddress.getAllByName(InetAddress.java:1171)
at java.net.InetAddress.getAllByName(InetAddress.java:1105)
dont know what is causing the issue, when i try with ip, it is working perfectly. Same host name when i try in chrome browser, it is working fine.. getting response from bacekend rest api..
{
"name" : "ip",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "q",
"version" : {
"number" : "7.9.3",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "c",
"build_date" : "2020-10-16T10:36:16.141335Z",
"build_snapshot" : false,
"lucene_version" : "8.6.2",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
http:/go-testand nothttp://go-test?HOST.URL=http:/go-testshouldHOST.URL=http://go-test.HttpHostconstructor, but from the error message HOST.URL should just be the host name.hostsfile.