# Connecting to embedded ES server instance from a different thread

**URL:** <https://discuss.elastic.co/t/connecting-to-embedded-es-server-instance-from-a-different-thread/42060>\
**Category:** Elasticsearch\
**Created:** [February 17, 2016, 6:17pm UTC](https://discuss.elastic.co/t/connecting-to-embedded-es-server-instance-from-a-different-thread/42060 "2016-02-17T18:17:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramdev\_Wudali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramdev_wudali/32/7894_2.png) [@Ramdev\_Wudali](https://discuss.elastic.co/u/Ramdev_Wudali)\
**Post date:** [February 17, 2016, 6:17pm UTC](https://discuss.elastic.co/t/connecting-to-embedded-es-server-instance-from-a-different-thread/42060/1 "2016-02-17T18:17:19Z")

</div>

Hi:  
I am trying to run an integration test of an application that connects to ES Cluster via either Node or Transport Client. However, I am running into some issues when connecting to the embedded ES instance.  
This is what I have done:

I start up an embedded ES instance with the following settings :

```
Settings elasticSearchSettings = Settings.settingsBuilder()
                                         .put("cluster.name","ES-INTEGRATION-TEST")
                                         .put("transport.tcp.port","9300")
                         .put("http.enabled", true)
                         .put("path.data", dataDirectory)
                         .put("path.home","/Volumes/3TBDrive/data/sdp/es_211_logs").build();

```

then I create a Client in another thread of the application like so :

```
  Settings settings = Settings.settingsBuilder().put("cluster.name", getESClusterName()).build();
    esClient = TransportClient.builder().settings(settings).build();
((TransportClient)esClient).addTransportAddresses(new InetSocketTransportAddress(
                                                   InetAddress.getByName(host), getESPort()));

```

where getESPost and getESClusterName return 9300 and "ES-INTEGRATION-TEST" respectively.  
However, when I execute the following command after creating the Transport Client :

`esClient.admin().indices().prepareExists(index).execute().actionGet().isExists();`

where index is the variable containing the index name, I get the error :

```
NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{127.0.0.1}{localhost/127.0.0.1:9300}]]
	at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:290)
	at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:207)
	at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
	at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:283)
	at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:347)
	at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1183)
	at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)
	at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)

```

I am running ES 2.1.1 with Java 8 JVM

any help is appreciated

After thought :

If I except the same command by 🙂  
`embeddedElasticServer.getClient.admin().cluster().prepareState().execute().actionGet().getState.prettyPrint()`

It works just fine.

Thanks much

Ramdev

---

<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:** [July 5, 2017, 11:15pm UTC](https://discuss.elastic.co/t/connecting-to-embedded-es-server-instance-from-a-different-thread/42060/2 "2017-07-05T23:15:35Z")

</div>


