<p dir="auto"><strong>Elasticsearch version</strong>:<br>
2.3.3</p>
<p dir="auto"><strong>Plugins installed</strong>: []<br>
head</p>
<p dir="auto"><strong>JVM version</strong>:</p>
<p dir="auto">java version "1.7.0_79"<br>
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)<br>
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)</p>
<p dir="auto"><strong>OS version</strong>:</p>
<p dir="auto">LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch<br>
Distributor ID: CentOS<br>
Description:    CentOS release 6.7 (Final)<br>
Release:        6.7<br>
Codename:       Final</p>
<p dir="auto"><strong>Description of the problem including expected versus actual behavior</strong>:</p>
<p dir="auto"><strong>Steps to reproduce</strong>:</p>
<ol dir="auto">
<li>
<p dir="auto">set es config</p>
<p dir="auto">cluster.name: es-tmp-cluster<br>
node.master: true<br>
node.data: false<br>
discovery.zen.ping.unicast.hosts: ["10.20.20.2:9300"]<br>
network.bind_host: 0.0.0.0<br>
network.publish_host: 10.20.20.2</p>
</li>
<li>
<p dir="auto">every node have two network card.  one is for public network  192.20.20.2  the other is for es private network is 10.20.20.2</p>
</li>
<li>
<p dir="auto">when i run set sniff to true</p>
</li>
</ol>
<p dir="auto">import org.elasticsearch.client.transport.TransportClient;<br>
import org.elasticsearch.common.settings.Settings;<br>
import org.elasticsearch.common.transport.InetSocketTransportAddress;</p>
<p dir="auto">import java.net.InetAddress;<br>
import java.net.UnknownHostException;</p>
<p dir="auto">/**</p>
<ul dir="auto">
<li>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="organization" data-hovercard-url="/orgs/author/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/author">@author</a> Ricky<br>
*/<br>
public class Test {</p>
<p dir="auto">public static void main(String[] args) throws UnknownHostException {</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Settings settings = Settings.settingsBuilder()
        .put(&quot;cluster.name&quot;, &quot;test-tmp-cluster&quot;)
        .put(&quot;client.transport.sniff&quot;, true)
        .put(&quot;client.transport.ignore_cluster_name&quot;, false)
        .put(&quot;client.transport.ping_timeout&quot;, &quot;30s&quot;)
        .put(&quot;client.transport.nodes_sampler_interval&quot;, &quot;5s&quot;)
        .build();


TransportClient client = TransportClient.builder().settings(settings).build()
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(&quot;192.20.20.2&quot;), 9300));

client.prepareIndex(&quot;test_index&quot;, &quot;test_type&quot;).setSource(&quot;{\&quot;name\&quot;:\&quot;Ricky\&quot;}&quot;).execute().actionGet();

client.close();"><pre class="notranslate"><code class="notranslate">Settings settings = Settings.settingsBuilder()
        .put("cluster.name", "test-tmp-cluster")
        .put("client.transport.sniff", true)
        .put("client.transport.ignore_cluster_name", false)
        .put("client.transport.ping_timeout", "30s")
        .put("client.transport.nodes_sampler_interval", "5s")
        .build();


TransportClient client = TransportClient.builder().settings(settings).build()
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("192.20.20.2"), 9300));

client.prepareIndex("test_index", "test_type").setSource("{\"name\":\"Ricky\"}").execute().actionGet();

client.close();
</code></pre></div>
<p dir="auto">}<br>
}</p>
</li>
</ul>
<p dir="auto"><strong>Provide logs (if relevant)</strong>:</p>
<p dir="auto">INFO: [Chan Luichow] modules [], plugins [], sites []<br>
Oct 13, 2016 10:19:55 PM org.elasticsearch.transport.netty.NettyTransport exceptionCaught<br>
WARNING: [Chan Luichow] exception caught on transport layer [[id: 0x0128ca17]], closing connection<br>
java.net.NoRouteToHostException: No route to host<br>
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)<br>
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)<br>
at org.jboss.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:152)<br>
at org.jboss.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105)<br>
at org.jboss.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79)<br>
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)<br>
at org.jboss.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42)<br>
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)<br>
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)<br>
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)<br>
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)<br>
at java.lang.Thread.run(Thread.java:745)</p>
<p dir="auto">Oct 13, 2016 10:19:56 PM org.elasticsearch.transport.netty.NettyTransport exceptionCaught<br>
WARNING: [Chan Luichow] exception caught on transport layer [[id: 0x9fabc4ac]], closing connection<br>
java.net.NoRouteToHostException: No route to host<br>
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)<br>
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)<br>
at org.jboss.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:152)<br>
at org.jboss.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105)<br>
at org.jboss.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79)<br>
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)<br>
at org.jboss.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42)<br>
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)<br>
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)<br>
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)<br>
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)<br>
at java.lang.Thread.run(Thread.java:745)</p>
<p dir="auto">Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{192.20.20.2}{192.20.20.2:9300}]]<br>
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:290)<br>
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:207)<br>
at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)<br>
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:288)<br>
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359)<br>
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86)<br>
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56)<br>
at Test.main(Test.java:33)</p>
<p dir="auto">When using the TransportClient with Sniffing, the Java application is using any of the profiles that you configure internally in the nodes. That way, is hard to separate the ports that the TransportClient uses to connect to the cluster, and the connections between the node.</p>
<p dir="auto">Using a static pool resolves the issue, because you just use a fixed list of Ips+Hosts.</p>
<p dir="auto">We should consider adding a new setting to the TransportClient to define a (set) of profiles (or default) so we don't use non-permitted endpoints when sniffing.</p>