title: Unable to create TransportClient in Elastic-Search
body: <p>I have been trying to create a TrasportClient in Elastic-Search but somehow not able to run it.</p>
  
  <p>Java code:</p>
  
  <pre><code>package es_example.custom;
  
  import org.elasticsearch.action.index.IndexResponse;
  import org.elasticsearch.client.Client;
  import org.elasticsearch.client.transport.TransportClient;
  import org.elasticsearch.common.settings.Settings;
  import org.elasticsearch.common.transport.InetSocketTransportAddress;
  import org.elasticsearch.node.NodeBuilder;
  
  
  import java.net.InetAddress;
  import java.net.UnknownHostException;
  import java.util.HashMap;
  import java.util.Map;
  
  public class EsRoutingTransportClient
  {
      // Both the IP addresses are replaced with valid IP addresses in code
      String ZEN_DISCOVERY_UNICAST_HOSTS_NO_JSON = "10.100.100.100,10.111.111.111";
  
      String ES_PATH_HOME = "/app/devuser/elasticsearch/dummy-path-home/";
  
      String ES_CLUSTER_NAME = "my-cluster"; // Verified cluster exists
  
      Integer ES_PORT = 9200;
  
      private Client client;
  
      public EsRoutingTransportClient()
      {
          String elasticSearchHost = ZEN_DISCOVERY_UNICAST_HOSTS_NO_JSON;
          Integer defaultPort = ES_PORT;
          String elasticSearchCluster = ES_CLUSTER_NAME;
  
          Settings settings = Settings.settingsBuilder()
                  .put("http.enabled", true)
                  .put("discovery.zen.ping.multicast.enabled", false)
                  // Both the IP addresses are replaced with valid IP addresses in code
                  .put("discovery.zen.ping.unicast.hosts", "[\"10.100.100.100\",\"10.111.111.111\"]")
                  .put("discovery.zen.minimum_master_nodes", 1)
                  .put("path.home", ES_PATH_HOME)
                  .build();
          client = TransportClient.builder().settings(settings).build();
          parseAndAddHostPort(elasticSearchHost, defaultPort);
      }
  
      private void parseAndAddHostPort(String elasticSearchHost, Integer defaultPort)
      {
          String [] esHosts = elasticSearchHost.split(",");
          for (String esHost: esHosts)
          {
              String [] hostPort = esHost.split(":");
              Integer esPort = defaultPort;
  
              if (hostPort.length == 2)
              {
                  esHost = hostPort[0];
                  esPort = Integer.parseInt(hostPort[1]);
              }
              try
              {
                  client = ((TransportClient)client).addTransportAddress(
                          new InetSocketTransportAddress(InetAddress.getByName(esHost), esPort));
                  System.out.println("Added " + esHost + " with port " + esPort + " as a transport address");
              } catch (UnknownHostException e) {
                  e.printStackTrace();
              }
          }
      }
  
      public void sendMessage (String msg, String indexName, String type, String id, String routing)
      {
          try
          {
              byte[] byteBuffer = msg.getBytes();
              IndexResponse response = client.prepareIndex(indexName, type, id)
                      .setSource(byteBuffer)
                      .execute()
                      .actionGet();
          }
          catch (Exception e)
          {
              e.printStackTrace();
          }
      }
  
      public static void main (String args[])
      {
          EsRoutingTransportClient esClient = new EsRoutingTransportClient();
          esClient.sendMessage("Hello", "storm", "json-trips", null, null);
      }
  }
  </code></pre>
  
  <p>pom.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;es_example&lt;/groupId&gt;
    &lt;artifactId&gt;es-proj&lt;/artifactId&gt;
    &lt;version&gt;0.0.3-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
    &lt;name&gt;es-proj&lt;/name&gt;
    &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;/properties&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.elasticsearch&lt;/groupId&gt;
        &lt;artifactId&gt;elasticsearch&lt;/artifactId&gt;
        &lt;version&gt;2.2.0&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;build&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.4.3&lt;/version&gt;
          &lt;configuration /&gt;
          &lt;executions&gt;
            &lt;execution&gt;
              &lt;phase&gt;package&lt;/phase&gt;
              &lt;goals&gt;
                &lt;goal&gt;shade&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                &lt;artifactSet&gt;
                  &lt;excludes&gt;
                    &lt;exlcude&gt;com.esotericsoftware.kryo:kryo:*&lt;/exlcude&gt;
                  &lt;/excludes&gt;
                &lt;/artifactSet&gt;
                &lt;transformers&gt;
                  &lt;transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /&gt;
                  &lt;transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"&gt;
                    &lt;mainClass&gt;es_example.custom.EsRoutingTransportClient&lt;/mainClass&gt;
                  &lt;/transformer&gt;
                &lt;/transformers&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I run it as follows:</p>
  
  <pre><code>mvn clean package
  java -jar target/es-proj-0.0.3-SNAPSHOT.jar
  </code></pre>
  
  <p>And this is the exception I get:</p>
  
  <pre><code>Mar 07, 2016 4:17:43 PM org.elasticsearch.plugins.PluginsService &lt;init&gt;
  INFO: [Bullseye] modules [], plugins [], sites []
  Mar 07, 2016 4:17:48 PM org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler doSample
  INFO: [Bullseye] failed to get node info for {#transport#-1}{10.100.100.100}{10.100.100.100:9200}, disconnecting...
  ReceiveTimeoutTransportException[[][10.100.100.100:9200][cluster:monitor/nodes/liveness] request_id [0] timed out after [5003ms]]
      at org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:645)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  
  Added 10.100.100.100 with port 9200 as a transport address
  Mar 07, 2016 4:17:53 PM org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler doSample
  INFO: [Bullseye] failed to get node info for {#transport#-1}{10.100.100.100}{10.100.100.100:9200}, disconnecting...
  ReceiveTimeoutTransportException[[][10.100.100.100:9200][cluster:monitor/nodes/liveness] request_id [1] timed out after [5002ms]]
      at org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:645)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  
  Mar 07, 2016 4:17:58 PM org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler doSample
  INFO: [Bullseye] failed to get node info for {#transport#-1}{10.100.100.100}{10.100.100.100:9200}, disconnecting...
  ReceiveTimeoutTransportException[[][10.100.100.100:9200][cluster:monitor/nodes/liveness] request_id [2] timed out after [5000ms]]
      at org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:645)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  
  Mar 07, 2016 4:18:03 PM org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler doSample
  INFO: [Bullseye] failed to get node info for {#transport#-2}{10.111.111.111}{10.111.111.111:9200}, disconnecting...
  ReceiveTimeoutTransportException[[][10.111.111.111:9200][cluster:monitor/nodes/liveness] request_id [3] timed out after [5001ms]]
      at org.elasticsearch.transport.TransportService$TimeoutHandler.run(TransportService.java:645)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  
  Added 10.111.111.111 with port 9200 as a transport address
  NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{10.100.100.100}{10.100.100.100:9200}, {#transport#-2}{10.111.111.111}{10.111.111.111:9200}]]
      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:286)
      at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:351)
      at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)
      at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)
      at es_example.custom.EsRoutingTransportClient.sendMessage(EsRoutingTransportClient.java:82)
      at es_example.custom.EsRoutingTransportClient.main(EsRoutingTransportClient.java:94)
  </code></pre>
  
  <p>Ping to both the hosts is working from the same terminal.</p>
  
  <p>(I have used 10.100.100.100 and 10.111.111.111 in the above example. In actually code-base, they are real valid IP addresses)</p>
  
  <p>Also one of the nodes mentioned in the list above is master and the other one is a data node.</p>
  
  <p>I am not sure how to fix this.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks!</p>