Connecting to embedded ES server instance from a different thread

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("http.enabled", true)
                         .put("", dataDirectory)

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

  Settings settings = Settings.settingsBuilder().put("", 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 :


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

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{}{localhost/}]]
	at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(
	at org.elasticsearch.client.transport.TransportClientNodesService.execute(
	at org.elasticsearch.client.transport.TransportClient.doExecute(
	at org.elasticsearch.action.ActionRequestBuilder.execute(
	at org.elasticsearch.action.ActionRequestBuilder.execute(

I am running ES 2.1.1 with Java 8 JVM

any help is appreciated

After thought :

If I except the same command by :slightly_smiling:

It works just fine.

Thanks much