# Connect to Elastic Cloud via PreBuiltXPackTransportClient

**URL:** <https://discuss.elastic.co/t/connect-to-elastic-cloud-via-prebuiltxpacktransportclient/146839>\
**Category:** Elasticsearch\
**Created:** [August 31, 2018, 9:28am UTC](https://discuss.elastic.co/t/connect-to-elastic-cloud-via-prebuiltxpacktransportclient/146839 "2018-08-31T09:28:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![occurred](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/occurred/32/35018_2.png) [@occurred](https://discuss.elastic.co/u/occurred)\
**Post date:** [August 31, 2018, 9:28am UTC](https://discuss.elastic.co/t/connect-to-elastic-cloud-via-prebuiltxpacktransportclient/146839/1 "2018-08-31T09:28:44Z")

</div>

I was following the instructions from here:  
[https://www.elastic.co/guide/en/x-pack/current/java-clients.html](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 😉 ):

```
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:

 ![36](https://us1.discourse-cdn.com/elastic/original/3X/4/b/4b9ddec4e71723c019d5d384099734071c352297.png)

My result for connectedNodes() is always empty.

---

<div class="post-metadata">

**Author:** ![occurred](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/occurred/32/35018_2.png) [@occurred](https://discuss.elastic.co/u/occurred)\
**Post date:** [September 5, 2018, 4:18am UTC](https://discuss.elastic.co/t/connect-to-elastic-cloud-via-prebuiltxpacktransportclient/146839/2 "2018-09-05T04:18:20Z")

</div>

My solution is the following:  
[https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.4/\_basic\_authentication.html](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...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 3, 2018, 4:18am UTC](https://discuss.elastic.co/t/connect-to-elastic-cloud-via-prebuiltxpacktransportclient/146839/3 "2018-10-03T04:18:29Z")

</div>

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