Connect to Elastic Cloud via PreBuiltXPackTransportClient

I was following the instructions from here:
https://www.elastic.co/guide/en/x-pack/current/java-clients.html

and just for my initial tests I've used the following example:

import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;

TransportClient client = new PreBuiltXPackTransportClient(Settings.builder()
    .put("cluster.name", "myClusterName")
    .put("xpack.security.user", "transport_client_user:x-pack-test-password")
    ...
    .build())

I'm adding the transport address like this (attention it's groovy code :wink: ):

InetAddress.getAllByName("elasticSearchAPIEndpoint_found_at_https://cloud.elastic.co/").each { address ->
    if ((address instanceof Inet6Address) || (address instanceof Inet4Address)) {
        client.addTransportAddress(new InetSocketTransportAddress(address, 9243))
    }
}

Of course with the correct address to my cloud instance and my correct xpack.security.user, also have created a new user in Kibana with role "transport_client".
ES version is 5.6.1
x-pack-transport: 5.6.1

These are the settings I can see when debugging:

My result for connectedNodes() is always empty.

My solution is the following:
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.4/_basic_authentication.html

It seems there is no way to get it working in the older versions...

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