# Converting Node Client to Transport client?

**URL:** <https://discuss.elastic.co/t/converting-node-client-to-transport-client/94844>\
**Category:** Elasticsearch\
**Created:** [July 27, 2017, 5:53pm UTC](https://discuss.elastic.co/t/converting-node-client-to-transport-client/94844 "2017-07-27T17:53:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![areddy7021](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/areddy7021/32/45289_2.png) [@areddy7021](https://discuss.elastic.co/u/areddy7021)\
**Post date:** [July 27, 2017, 5:53pm UTC](https://discuss.elastic.co/t/converting-node-client-to-transport-client/94844/1 "2017-07-27T17:53:06Z")

</div>

I am facing an issue while converting the node client to transport client , can any one please guide me on the conversion , It is saying none of the configured nodes available.

Do any one has any snippet to create a transport client , i am doing with the embedded elastic search server start up in junit test case to connect via transport client , please post any thoughts or ideas to create an embedded es server and connect through transport client .

Thanks,

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 27, 2017, 6:09pm UTC](https://discuss.elastic.co/t/converting-node-client-to-transport-client/94844/2 "2017-07-27T18:09:16Z")

</div>

Starting Elasticsearch embedded is not supported.

You should start an external node then run your tests against it.

My 2 cents

---

<div class="post-metadata">

**Author:** ![areddy7021](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/areddy7021/32/45289_2.png) [@areddy7021](https://discuss.elastic.co/u/areddy7021)\
**Post date:** [July 27, 2017, 8:36pm UTC](https://discuss.elastic.co/t/converting-node-client-to-transport-client/94844/3 "2017-07-27T20:36:43Z")

</div>

Hi David , starting up the custom embedded es cluster and shutting down once after all the unit test are done. And he was using the node client during that time and we decided to go with the transport client and there is the actual issue.

Here is the custom class where we have written to start up embedded one :

```auto
  public EmbeddedElasticsearchServer(String clusterName) {
        this.clusterName = clusterName;
        this.dataDirectory = DEFAULT_DATA_DIRECTORY + this.clusterName;
        LOGGER.info("######### Starting embedded elastic search cluster, name = {} in directory = {}", clusterName, this.dataDirectory);
        /* Clean directory before starting server */
        File dataDirectory = new File(this.dataDirectory);
        if (dataDirectory.exists()) {
            EmbeddedElasticsearchServer.deleteDataDirectory(this.dataDirectory);
        }
        this.elasticsearchSettings = ImmutableSettings.settingsBuilder()
                .put("http.enabled", "false")
                .put("path.data", this.dataDirectory)
                .put("index.number_of_replicas", 0)
                .build();
        node = createLocalNode();
        client = this.node.client();
        esClients = new ArrayList<>();
        esClients.add(client);
    }

    public Node createLocalNode() {
        return nodeBuilder()
                .local(true)
                .settings(this.elasticsearchSettings)
                .clusterName(this.clusterName)
                .node();
    }

    public static void deleteDataDirectory(String directory) {
        LOGGER.info("Deleting directory = {}", directory);
        try {
            FileUtils.forceDelete(new File(directory));
        } catch (IOException e) {
            LOGGER.error("Unable to delete directory = {} due to exception = {}", directory, ExceptionUtils.getStackTrace(e));
        }
    }

    @Override
    public Client getClient() {
        return client;
    }

    @Override
    public ArrayList<Client> getEsClients() {
        return esClients;
    }

    @Override
    public void shutDown() {
        String nodeName = node.settings().get("name");
        LOGGER.info("######### Stopping embedded elastic search client and node = " + nodeName);
        this.getEsClients().forEach(client -> client.close());
        node.close();
        LOGGER.info("######### Stopped embedded elastic search node = " + nodeName + ", is closed = " + node.isClosed());
        EmbeddedElasticsearchServer.deleteDataDirectory(this.dataDirectory);
    }

```

and that was the place where i was trying to inject esclient as transport client instead of node client and i ended up with the none of the configured nodes exception.

thank you for your help...

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 28, 2017, 8:10am UTC](https://discuss.elastic.co/t/converting-node-client-to-transport-client/94844/4 "2017-07-28T08:10:22Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

I edited your post.

As I said, running elasticsearch embedded is not supported.

When testing, I'm using [elasticsearch-maven-plugin](https://github.com/alexcojocaru/elasticsearch-maven-plugin) and I'm just creating a TransportClient from my tests:

Something like:

> <https://github.com/dadoonet/spring-elasticsearch/blob/master/src/test/java/fr/pilato/spring/elasticsearch/it/BaseTest.java#L45-L62>

```auto
    @BeforeClass
    public static void testElasticsearchIsRunning() {
        try {
            client = new PreBuiltTransportClient(Settings.builder().put("client.transport.ignore_cluster_name", true).build())
                    .addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));
            client.admin().cluster().prepareHealth().setTimeout(TimeValue.timeValueMillis(200)).get();
        } catch (Exception e) {
            assumeNoException(e);
        }
    }

    @AfterClass
    public static void stopClient() {
        if (client != null) {
            client.close();
            client = null;
        }
    }

```

---

<div class="post-metadata">

**Author:** ![areddy7021](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/areddy7021/32/45289_2.png) [@areddy7021](https://discuss.elastic.co/u/areddy7021)\
**Post date:** [August 10, 2017, 9:22pm UTC](https://discuss.elastic.co/t/converting-node-client-to-transport-client/94844/5 "2017-08-10T21:22:20Z")

</div>

> [@dadoonet](#):
>
> try {  
> client = new PreBuiltTransportClient(Settings.builder().put("client.transport.ignore\_cluster\_name", true).build())  
> .addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));  
> client.admin().cluster().prepareHealth().setTimeout(TimeValue.timeValueMillis(200)).get();  
> } catch (Exception e) {  
> assumeNoException(e);  
> }

Thank you for the suggestion but my issue is different where i am using es version of 1.3 and there is no prebuilt transport client for es version of 1.3 and i didnt get your statement that there is no embedded support or embedded es setup available , if that is the case we are doing by ourself by setting up node and cluster and reaching out via node client , the same embedded cluster i want to use but i have to get with the transport client instead of node client which i have written the above code. Please let me know if i am missing something here ..i really appreciate the help from the community. I mean i am requesting that the proper conversion technique of moving away from node client to transport client with the es version of 1.3.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 11, 2017, 8:27am UTC](https://discuss.elastic.co/t/converting-node-client-to-transport-client/94844/6 "2017-08-11T08:27:13Z")

</div>

You really need to upgrade.

1.7 is not supported anymore.  
2.4 is going to enter the EOL period soon as 6.0 GA will be released.

Anyway here is the doc for your version : [https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.3/transport-client.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.3/transport-client.html)

---

<div class="post-metadata">

**Author:** ![areddy7021](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/areddy7021/32/45289_2.png) [@areddy7021](https://discuss.elastic.co/u/areddy7021)\
**Post date:** [August 14, 2017, 5:29pm UTC](https://discuss.elastic.co/t/converting-node-client-to-transport-client/94844/7 "2017-08-14T17:29:39Z")

</div>

thank you ...but do you see any issue in connecting the created node through transport client instead of node client ? i mean i am able to do the same setup and successful operations with the node client and not able to do with the transport client..i have followed the documentation and provided all the settings needed but still it says none of the configured nodes exception. is there any way which can create a local node with the node builder and access through transport client ?

---

<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:** [September 11, 2017, 5:29pm UTC](https://discuss.elastic.co/t/converting-node-client-to-transport-client/94844/8 "2017-09-11T17:29:41Z")

</div>

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