NoNodeAvailableException

Hello,

I'm having trouble connecting to elasticsearch through the Java API. I
have two servers, each running elastic search and my java application
(Play! Framework). I can connect to elasticsearch using curl on port
9200, for example:
$ curl -XGET server1:9200/_cluster/health
{"cluster_name":"elasticsearch","status":"yellow","timed_out":false,"number_of_nodes":
1,"number_of_data_nodes":1,"active_primary_shards":5,"active_shards":
5,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":5}

But when I try to connect with the Java API on port 9300, I get a
NoNodeAvailableException. I've opened ports 9200 and 9300 on my
firewall. The ES log on each server, and the cluster health above,
seem to indicate that the two instances of elastic search aren't
connecting to each other. I read in a few other threads that this is
often caused by mismatched cluster names, but I'm using the default
value, "elasticsearch".

What am I doing wrong?

Stack trace:
play.exceptions.JavaExecutionException: No node available
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
at Invocation.HTTP Request(Play!)
Caused by:
org.elasticsearch.client.transport.NoNodeAvailableException: No node
available
at
org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:
145)
at
org.elasticsearch.client.transport.support.InternalTransportClusterAdminClient.state(InternalTransportClusterAdminClient.java:
125)
at controllers.Search.index(Search.java:36)

/etc/elasticsearch/elasticsearch.yml config file (Elastic search is
set up as a service, as described at
http://www.elasticsearch.org/tutorials/2010/07/02/setting-up-elasticsearch-on-debian.html):
cluster:
name: elasticsearch
network:
host: eth1:ipv4

Elastic Search logs:
Server 1:
[2011-12-22 16:47:25,350][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: initializing ...
[2011-12-22 16:47:25,365][INFO ][plugins ] [Fight-
Man] loaded [], sites []
[2011-12-22 16:47:28,228][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: initialized
[2011-12-22 16:47:28,229][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: starting ...
[2011-12-22 16:47:28,324][INFO ][transport ] [Fight-
Man] bound_address {inet[/10.182.35.60:9300]}, publish_address {inet[/
10.182.1.2:9300]}
[2011-12-22 16:47:31,369][INFO ][cluster.service ] [Fight-
Man] new_master [Fight-Man][D_A18QcATlaFPE28FI5-gg][inet[/
10.182.1.2:9300]], reason: zen-disco-join (elected_as_master)
[2011-12-22 16:47:31,444][INFO ][discovery ] [Fight-
Man] elasticsearch/D_A18QcATlaFPE28FI5-gg
[2011-12-22 16:47:31,678][INFO ][http ] [Fight-
Man] bound_address {inet[/10.182.35.60:9200]}, publish_address {inet[/
10.182.1.2:9200]}
[2011-12-22 16:47:31,679][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: started
[2011-12-22 16:47:32,393][INFO ][gateway ] [Fight-
Man] recovered [1] indices into cluster_state

Server 2:
[2011-12-22 16:52:10,402][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: initializing ...
[2011-12-22 16:52:10,411][INFO ][plugins ] [Jack-in-
the-Box] loaded [], sites []
[2011-12-22 16:52:13,505][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: initialized
[2011-12-22 16:52:13,507][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: starting ...
[2011-12-22 16:52:13,659][INFO ][transport ] [Jack-in-
the-Box] bound_address {inet[/10.182.33.113:9300]}, publish_address
{inet[/10.182.3.4:9300]}
[2011-12-22 16:52:16,815][INFO ][cluster.service ] [Jack-in-
the-Box] new_master [Jack-in-the-Box][tCfshMH-Q1KbsK6eYUTthw][inet[/
10.182.3.4:9300]], reason: zen-disco-join (elected_as_master)
[2011-12-22 16:52:16,857][INFO ][discovery ] [Jack-in-
the-Box] elasticsearch/tCfshMH-Q1KbsK6eYUTthw
[2011-12-22 16:52:16,950][INFO ][http ] [Jack-in-
the-Box] bound_address {inet[/10.182.33.113:9200]}, publish_address
{inet[/10.182.3.4:9200]}
[2011-12-22 16:52:16,953][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: started
[2011-12-22 16:52:16,967][INFO ][gateway ] [Jack-in-
the-Box] recovered [0] indices into cluster_state

My Java code:
public class Search extends Controller {

@Get("/cluster")
public static void index() {
    Settings settings = ImmutableSettings.settingsBuilder()
        .put("cluster.name", "elasticsearch").build();
    TransportClient client = new TransportClient(settings)
        .addTransportAddress(new

InetSocketTransportAddress("10.182.1.2", 9300))
.addTransportAddress(new
InetSocketTransportAddress("10.182.3.4", 9300));
ActionFuture response =
client.admin().cluster().state(new ClusterStateRequest()); // Throws
exception
renderText(response.actionGet().getClusterName().toString());
}

@Get("/cluster/node")
public static void node() {
    Node node = nodeBuilder().data(false).node();
    Client client = node.client();
    ActionFuture<ClusterStateResponse> response =

client.admin().cluster().state(new ClusterStateRequest());

renderText(response.actionGet().state().getNodes().dataNodes().keySet()); //
Output is []
}
}

iptables rules:
ACCEPT tcp -- server1 anywhere tcp dpt:9200
ACCEPT tcp -- server2 anywhere tcp dpt:9200
ACCEPT udp -- server1 anywhere udp dpt:9300
ACCEPT udp -- server2 anywhere udp dpt:9300
ACCEPT tcp -- server1 anywhere tcp dpt:9300
ACCEPT tcp -- server2 anywhere tcp dpt:9300

I now have the two nodes communicating with each other, but am still
unable to access them through the Java API's TransportClient.

My servers are in Rackspace, and since multicast is disabled there, I
needed to use unicast to get them to discover each other:
discovery:
zen:
ping:
multicast:
enabled: false
unicast:
hosts: "server1:9300,server2:9300"

The second server to start now detects the other as the master, and
through curl, I can see that what I PUT to one, I can GET from the
other.

What settings do I need to use when setting up the TransportClient? Do
I need unicast here? I'm currently doing the following:

    Settings settings = ImmutableSettings.settingsBuilder()
        .put("cluster.name", "elasticsearch")
        .put("client.transport.sniff", true)
        .put("discovery.zen.ping.multicast.enabled", false)
        .put("discovery.zen.ping.unicast.enabled", true)
        .put("discovery.zen.ping.unicast.hosts",

"server1:9300,server2:9300")
.put("discovery.zen.multicast.enabled", false)
.put("discovery.zen.unicast.enabled", true)
.put("discovery.zen.unicast.hosts",
"server1:9300,server2:9300").build();
TransportClient client = new TransportClient(settings)
.addTransportAddress(new
InetSocketTransportAddress("server1", 9300))
.addTransportAddress(new
InetSocketTransportAddress("server2", 9300));
NodesInfoResponse rsp = client.admin().cluster().nodesInfo(new
NodesInfoRequest()).actionGet();
String str = "Cluster:" + rsp.getClusterName() + ". Active
nodes:";
str += rsp.getNodesMap().keySet();
renderText(str);

On Dec 22, 12:27 pm, David Loehr dlo...@servicetask.com wrote:

Hello,

I'm having trouble connecting to elasticsearch through the Java API. I
have two servers, each running Elasticsearch and my java application
(Play! Framework). I can connect to elasticsearch using curl on port
9200, for example:
$ curl -XGET server1:9200/_cluster/health
{"cluster_name":"elasticsearch","status":"yellow","timed_out":false,"number _of_nodes":
1,"number_of_data_nodes":1,"active_primary_shards":5,"active_shards":
5,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":5}

But when I try to connect with the Java API on port 9300, I get a
NoNodeAvailableException. I've opened ports 9200 and 9300 on my
firewall. The ES log on each server, and the cluster health above,
seem to indicate that the two instances of Elasticsearch aren't
connecting to each other. I read in a few other threads that this is
often caused by mismatched cluster names, but I'm using the default
value, "elasticsearch".

What am I doing wrong?

Stack trace:
play.exceptions.JavaExecutionException: No node available
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
at Invocation.HTTP Request(Play!)
Caused by:
org.elasticsearch.client.transport.NoNodeAvailableException: No node
available
at
org.elasticsearch.client.transport.TransportClientNodesService.execute(Tran sportClientNodesService.java:
145)
at
org.elasticsearch.client.transport.support.InternalTransportClusterAdminCli ent.state(InternalTransportClusterAdminClient.java:
125)
at controllers.Search.index(Search.java:36)

/etc/elasticsearch/elasticsearch.yml config file (Elastic search is
set up as a service, as described athttp://www.elasticsearch.org/tutorials/2010/07/02/setting-up-elastics...
cluster:
name: elasticsearch
network:
host: eth1:ipv4

Elastic Search logs:
Server 1:
[2011-12-22 16:47:25,350][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: initializing ...
[2011-12-22 16:47:25,365][INFO ][plugins ] [Fight-
Man] loaded , sites
[2011-12-22 16:47:28,228][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: initialized
[2011-12-22 16:47:28,229][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: starting ...
[2011-12-22 16:47:28,324][INFO ][transport ] [Fight-
Man] bound_address {inet[/10.182.35.60:9300]}, publish_address {inet[/
10.182.1.2:9300]}
[2011-12-22 16:47:31,369][INFO ][cluster.service ] [Fight-
Man] new_master [Fight-Man][D_A18QcATlaFPE28FI5-gg][inet[/
10.182.1.2:9300]], reason: zen-disco-join (elected_as_master)
[2011-12-22 16:47:31,444][INFO ][discovery ] [Fight-
Man] elasticsearch/D_A18QcATlaFPE28FI5-gg
[2011-12-22 16:47:31,678][INFO ][http ] [Fight-
Man] bound_address {inet[/10.182.35.60:9200]}, publish_address {inet[/
10.182.1.2:9200]}
[2011-12-22 16:47:31,679][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: started
[2011-12-22 16:47:32,393][INFO ][gateway ] [Fight-
Man] recovered [1] indices into cluster_state

Server 2:
[2011-12-22 16:52:10,402][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: initializing ...
[2011-12-22 16:52:10,411][INFO ][plugins ] [Jack-in-
the-Box] loaded , sites
[2011-12-22 16:52:13,505][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: initialized
[2011-12-22 16:52:13,507][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: starting ...
[2011-12-22 16:52:13,659][INFO ][transport ] [Jack-in-
the-Box] bound_address {inet[/10.182.33.113:9300]}, publish_address
{inet[/10.182.3.4:9300]}
[2011-12-22 16:52:16,815][INFO ][cluster.service ] [Jack-in-
the-Box] new_master [Jack-in-the-Box][tCfshMH-Q1KbsK6eYUTthw][inet[/
10.182.3.4:9300]], reason: zen-disco-join (elected_as_master)
[2011-12-22 16:52:16,857][INFO ][discovery ] [Jack-in-
the-Box] elasticsearch/tCfshMH-Q1KbsK6eYUTthw
[2011-12-22 16:52:16,950][INFO ][http ] [Jack-in-
the-Box] bound_address {inet[/10.182.33.113:9200]}, publish_address
{inet[/10.182.3.4:9200]}
[2011-12-22 16:52:16,953][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: started
[2011-12-22 16:52:16,967][INFO ][gateway ] [Jack-in-
the-Box] recovered [0] indices into cluster_state

My Java code:
public class Search extends Controller {

@Get("/cluster")
public static void index() {
    Settings settings = ImmutableSettings.settingsBuilder()
        .put("cluster.name", "elasticsearch").build();
    TransportClient client = new TransportClient(settings)
        .addTransportAddress(new

InetSocketTransportAddress("10.182.1.2", 9300))
.addTransportAddress(new
InetSocketTransportAddress("10.182.3.4", 9300));
ActionFuture response =
client.admin().cluster().state(new ClusterStateRequest()); // Throws
exception
renderText(response.actionGet().getClusterName().toString());
}

@Get("/cluster/node")
public static void node() {
    Node node = nodeBuilder().data(false).node();
    Client client = node.client();
    ActionFuture<ClusterStateResponse> response =

client.admin().cluster().state(new ClusterStateRequest());

renderText(response.actionGet().state().getNodes().dataNodes().keySet()); //
Output is
}

}

iptables rules:
ACCEPT tcp -- server1 anywhere tcp dpt:9200
ACCEPT tcp -- server2 anywhere tcp dpt:9200
ACCEPT udp -- server1 anywhere udp dpt:9300
ACCEPT udp -- server2 anywhere udp dpt:9300
ACCEPT tcp -- server1 anywhere tcp dpt:9300
ACCEPT tcp -- server2 anywhere tcp dpt:9300

Transport client does not need the zen discovery settings to be applied to
it, since it does no discovery. It connects directly to the provided
servers. You can set org.elasticsearch.client.transport to TRACE level in
your logging configuration (on the client side) to see the failures it has
(to connect for example).

On Thu, Dec 22, 2011 at 11:44 PM, David Loehr dloehr@servicetask.comwrote:

I now have the two nodes communicating with each other, but am still
unable to access them through the Java API's TransportClient.

My servers are in Rackspace, and since multicast is disabled there, I
needed to use unicast to get them to discover each other:
discovery:
zen:
ping:
multicast:
enabled: false
unicast:
hosts: "server1:9300,server2:9300"

The second server to start now detects the other as the master, and
through curl, I can see that what I PUT to one, I can GET from the
other.

What settings do I need to use when setting up the TransportClient? Do
I need unicast here? I'm currently doing the following:

   Settings settings = ImmutableSettings.settingsBuilder()
       .put("cluster.name", "elasticsearch")
        .put("client.transport.sniff", true)
       .put("discovery.zen.ping.multicast.enabled", false)
       .put("discovery.zen.ping.unicast.enabled", true)
       .put("discovery.zen.ping.unicast.hosts",

"server1:9300,server2:9300")
.put("discovery.zen.multicast.enabled", false)
.put("discovery.zen.unicast.enabled", true)
.put("discovery.zen.unicast.hosts",
"server1:9300,server2:9300").build();
TransportClient client = new TransportClient(settings)
.addTransportAddress(new
InetSocketTransportAddress("server1", 9300))
.addTransportAddress(new
InetSocketTransportAddress("server2", 9300));
NodesInfoResponse rsp = client.admin().cluster().nodesInfo(new
NodesInfoRequest()).actionGet();
String str = "Cluster:" + rsp.getClusterName() + ". Active
nodes:";
str += rsp.getNodesMap().keySet();
renderText(str);

On Dec 22, 12:27 pm, David Loehr dlo...@servicetask.com wrote:

Hello,

I'm having trouble connecting to elasticsearch through the Java API. I
have two servers, each running Elasticsearch and my java application
(Play! Framework). I can connect to elasticsearch using curl on port
9200, for example:
$ curl -XGET server1:9200/_cluster/health

{"cluster_name":"elasticsearch","status":"yellow","timed_out":false,"number
_of_nodes":

1,"number_of_data_nodes":1,"active_primary_shards":5,"active_shards":
5,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":5}

But when I try to connect with the Java API on port 9300, I get a
NoNodeAvailableException. I've opened ports 9200 and 9300 on my
firewall. The ES log on each server, and the cluster health above,
seem to indicate that the two instances of Elasticsearch aren't
connecting to each other. I read in a few other threads that this is
often caused by mismatched cluster names, but I'm using the default
value, "elasticsearch".

What am I doing wrong?

Stack trace:
play.exceptions.JavaExecutionException: No node available
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
at Invocation.HTTP Request(Play!)
Caused by:
org.elasticsearch.client.transport.NoNodeAvailableException: No node
available
at

org.elasticsearch.client.transport.TransportClientNodesService.execute(Tran
sportClientNodesService.java:

  1. at

org.elasticsearch.client.transport.support.InternalTransportClusterAdminCli
ent.state(InternalTransportClusterAdminClient.java:

  1. at controllers.Search.index(Search.java:36)

/etc/elasticsearch/elasticsearch.yml config file (Elastic search is
set up as a service, as described athttp://
Elasticsearch Platform — Find real-time answers at scale | Elastic...
cluster:
name: elasticsearch
network:
host: eth1:ipv4

Elastic Search logs:
Server 1:
[2011-12-22 16:47:25,350][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: initializing ...
[2011-12-22 16:47:25,365][INFO ][plugins ] [Fight-
Man] loaded , sites
[2011-12-22 16:47:28,228][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: initialized
[2011-12-22 16:47:28,229][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: starting ...
[2011-12-22 16:47:28,324][INFO ][transport ] [Fight-
Man] bound_address {inet[/10.182.35.60:9300]}, publish_address {inet[/
10.182.1.2:9300]}
[2011-12-22 16:47:31,369][INFO ][cluster.service ] [Fight-
Man] new_master [Fight-Man][D_A18QcATlaFPE28FI5-gg][inet[/
10.182.1.2:9300]], reason: zen-disco-join (elected_as_master)
[2011-12-22 16:47:31,444][INFO ][discovery ] [Fight-
Man] elasticsearch/D_A18QcATlaFPE28FI5-gg
[2011-12-22 16:47:31,678][INFO ][http ] [Fight-
Man] bound_address {inet[/10.182.35.60:9200]}, publish_address {inet[/
10.182.1.2:9200]}
[2011-12-22 16:47:31,679][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: started
[2011-12-22 16:47:32,393][INFO ][gateway ] [Fight-
Man] recovered [1] indices into cluster_state

Server 2:
[2011-12-22 16:52:10,402][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: initializing ...
[2011-12-22 16:52:10,411][INFO ][plugins ] [Jack-in-
the-Box] loaded , sites
[2011-12-22 16:52:13,505][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: initialized
[2011-12-22 16:52:13,507][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: starting ...
[2011-12-22 16:52:13,659][INFO ][transport ] [Jack-in-
the-Box] bound_address {inet[/10.182.33.113:9300]}, publish_address
{inet[/10.182.3.4:9300]}
[2011-12-22 16:52:16,815][INFO ][cluster.service ] [Jack-in-
the-Box] new_master [Jack-in-the-Box][tCfshMH-Q1KbsK6eYUTthw][inet[/
10.182.3.4:9300]], reason: zen-disco-join (elected_as_master)
[2011-12-22 16:52:16,857][INFO ][discovery ] [Jack-in-
the-Box] elasticsearch/tCfshMH-Q1KbsK6eYUTthw
[2011-12-22 16:52:16,950][INFO ][http ] [Jack-in-
the-Box] bound_address {inet[/10.182.33.113:9200]}, publish_address
{inet[/10.182.3.4:9200]}
[2011-12-22 16:52:16,953][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: started
[2011-12-22 16:52:16,967][INFO ][gateway ] [Jack-in-
the-Box] recovered [0] indices into cluster_state

My Java code:
public class Search extends Controller {

@Get("/cluster")
public static void index() {
    Settings settings = ImmutableSettings.settingsBuilder()
        .put("cluster.name", "elasticsearch").build();
    TransportClient client = new TransportClient(settings)
        .addTransportAddress(new

InetSocketTransportAddress("10.182.1.2", 9300))
.addTransportAddress(new
InetSocketTransportAddress("10.182.3.4", 9300));
ActionFuture response =
client.admin().cluster().state(new ClusterStateRequest()); // Throws
exception
renderText(response.actionGet().getClusterName().toString());
}

@Get("/cluster/node")
public static void node() {
    Node node = nodeBuilder().data(false).node();
    Client client = node.client();
    ActionFuture<ClusterStateResponse> response =

client.admin().cluster().state(new ClusterStateRequest());

renderText(response.actionGet().state().getNodes().dataNodes().keySet()); //

Output is
}

}

iptables rules:
ACCEPT tcp -- server1 anywhere tcp dpt:9200
ACCEPT tcp -- server2 anywhere tcp dpt:9200
ACCEPT udp -- server1 anywhere udp dpt:9300
ACCEPT udp -- server2 anywhere udp dpt:9300
ACCEPT tcp -- server1 anywhere tcp dpt:9300
ACCEPT tcp -- server2 anywhere tcp dpt:9300

Also, try and set sniff to false (the default). When sniffing it turned on,
it will try to connect to the publish host of each node (its logged on each
node when it starts up), which might not be the IP you want to connect
through.

On Fri, Dec 23, 2011 at 1:51 AM, Shay Banon kimchy@gmail.com wrote:

Transport client does not need the zen discovery settings to be applied to
it, since it does no discovery. It connects directly to the provided
servers. You can set org.elasticsearch.client.transport to TRACE level in
your logging configuration (on the client side) to see the failures it has
(to connect for example).

On Thu, Dec 22, 2011 at 11:44 PM, David Loehr dloehr@servicetask.comwrote:

I now have the two nodes communicating with each other, but am still
unable to access them through the Java API's TransportClient.

My servers are in Rackspace, and since multicast is disabled there, I
needed to use unicast to get them to discover each other:
discovery:
zen:
ping:
multicast:
enabled: false
unicast:
hosts: "server1:9300,server2:9300"

The second server to start now detects the other as the master, and
through curl, I can see that what I PUT to one, I can GET from the
other.

What settings do I need to use when setting up the TransportClient? Do
I need unicast here? I'm currently doing the following:

   Settings settings = ImmutableSettings.settingsBuilder()
       .put("cluster.name", "elasticsearch")
        .put("client.transport.sniff", true)
       .put("discovery.zen.ping.multicast.enabled", false)
       .put("discovery.zen.ping.unicast.enabled", true)
       .put("discovery.zen.ping.unicast.hosts",

"server1:9300,server2:9300")
.put("discovery.zen.multicast.enabled", false)
.put("discovery.zen.unicast.enabled", true)
.put("discovery.zen.unicast.hosts",
"server1:9300,server2:9300").build();
TransportClient client = new TransportClient(settings)
.addTransportAddress(new
InetSocketTransportAddress("server1", 9300))
.addTransportAddress(new
InetSocketTransportAddress("server2", 9300));
NodesInfoResponse rsp = client.admin().cluster().nodesInfo(new
NodesInfoRequest()).actionGet();
String str = "Cluster:" + rsp.getClusterName() + ". Active
nodes:";
str += rsp.getNodesMap().keySet();
renderText(str);

On Dec 22, 12:27 pm, David Loehr dlo...@servicetask.com wrote:

Hello,

I'm having trouble connecting to elasticsearch through the Java API. I
have two servers, each running Elasticsearch and my java application
(Play! Framework). I can connect to elasticsearch using curl on port
9200, for example:
$ curl -XGET server1:9200/_cluster/health

{"cluster_name":"elasticsearch","status":"yellow","timed_out":false,"number
_of_nodes":

1,"number_of_data_nodes":1,"active_primary_shards":5,"active_shards":
5,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":5}

But when I try to connect with the Java API on port 9300, I get a
NoNodeAvailableException. I've opened ports 9200 and 9300 on my
firewall. The ES log on each server, and the cluster health above,
seem to indicate that the two instances of Elasticsearch aren't
connecting to each other. I read in a few other threads that this is
often caused by mismatched cluster names, but I'm using the default
value, "elasticsearch".

What am I doing wrong?

Stack trace:
play.exceptions.JavaExecutionException: No node available
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
at Invocation.HTTP Request(Play!)
Caused by:
org.elasticsearch.client.transport.NoNodeAvailableException: No node
available
at

org.elasticsearch.client.transport.TransportClientNodesService.execute(Tran
sportClientNodesService.java:

  1. at

org.elasticsearch.client.transport.support.InternalTransportClusterAdminCli
ent.state(InternalTransportClusterAdminClient.java:

  1. at controllers.Search.index(Search.java:36)

/etc/elasticsearch/elasticsearch.yml config file (Elastic search is
set up as a service, as described athttp://
Elasticsearch Platform — Find real-time answers at scale | Elastic...
cluster:
name: elasticsearch
network:
host: eth1:ipv4

Elastic Search logs:
Server 1:
[2011-12-22 16:47:25,350][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: initializing ...
[2011-12-22 16:47:25,365][INFO ][plugins ] [Fight-
Man] loaded , sites
[2011-12-22 16:47:28,228][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: initialized
[2011-12-22 16:47:28,229][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: starting ...
[2011-12-22 16:47:28,324][INFO ][transport ] [Fight-
Man] bound_address {inet[/10.182.35.60:9300]}, publish_address {inet[/
10.182.1.2:9300]}
[2011-12-22 16:47:31,369][INFO ][cluster.service ] [Fight-
Man] new_master [Fight-Man][D_A18QcATlaFPE28FI5-gg][inet[/
10.182.1.2:9300]], reason: zen-disco-join (elected_as_master)
[2011-12-22 16:47:31,444][INFO ][discovery ] [Fight-
Man] elasticsearch/D_A18QcATlaFPE28FI5-gg
[2011-12-22 16:47:31,678][INFO ][http ] [Fight-
Man] bound_address {inet[/10.182.35.60:9200]}, publish_address {inet[/
10.182.1.2:9200]}
[2011-12-22 16:47:31,679][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: started
[2011-12-22 16:47:32,393][INFO ][gateway ] [Fight-
Man] recovered [1] indices into cluster_state

Server 2:
[2011-12-22 16:52:10,402][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: initializing ...
[2011-12-22 16:52:10,411][INFO ][plugins ] [Jack-in-
the-Box] loaded , sites
[2011-12-22 16:52:13,505][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: initialized
[2011-12-22 16:52:13,507][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: starting ...
[2011-12-22 16:52:13,659][INFO ][transport ] [Jack-in-
the-Box] bound_address {inet[/10.182.33.113:9300]}, publish_address
{inet[/10.182.3.4:9300]}
[2011-12-22 16:52:16,815][INFO ][cluster.service ] [Jack-in-
the-Box] new_master [Jack-in-the-Box][tCfshMH-Q1KbsK6eYUTthw][inet[/
10.182.3.4:9300]], reason: zen-disco-join (elected_as_master)
[2011-12-22 16:52:16,857][INFO ][discovery ] [Jack-in-
the-Box] elasticsearch/tCfshMH-Q1KbsK6eYUTthw
[2011-12-22 16:52:16,950][INFO ][http ] [Jack-in-
the-Box] bound_address {inet[/10.182.33.113:9200]}, publish_address
{inet[/10.182.3.4:9200]}
[2011-12-22 16:52:16,953][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: started
[2011-12-22 16:52:16,967][INFO ][gateway ] [Jack-in-
the-Box] recovered [0] indices into cluster_state

My Java code:
public class Search extends Controller {

@Get("/cluster")
public static void index() {
    Settings settings = ImmutableSettings.settingsBuilder()
        .put("cluster.name", "elasticsearch").build();
    TransportClient client = new TransportClient(settings)
        .addTransportAddress(new

InetSocketTransportAddress("10.182.1.2", 9300))
.addTransportAddress(new
InetSocketTransportAddress("10.182.3.4", 9300));
ActionFuture response =
client.admin().cluster().state(new ClusterStateRequest()); // Throws
exception
renderText(response.actionGet().getClusterName().toString());
}

@Get("/cluster/node")
public static void node() {
    Node node = nodeBuilder().data(false).node();
    Client client = node.client();
    ActionFuture<ClusterStateResponse> response =

client.admin().cluster().state(new ClusterStateRequest());

renderText(response.actionGet().state().getNodes().dataNodes().keySet()); //

Output is
}

}

iptables rules:
ACCEPT tcp -- server1 anywhere tcp dpt:9200
ACCEPT tcp -- server2 anywhere tcp dpt:9200
ACCEPT udp -- server1 anywhere udp dpt:9300
ACCEPT udp -- server2 anywhere udp dpt:9300
ACCEPT tcp -- server1 anywhere tcp dpt:9300
ACCEPT tcp -- server2 anywhere tcp dpt:9300

Thank you! After we turned on TRACE logging, we discovered that we
were using an outdated elasticsearch jar for the client, 0.17.6, and
0.18.6 for the standalone nodes. Upgrading to 0.18.6 fixed the issue.

On Dec 22, 6:59 pm, Shay Banon kim...@gmail.com wrote:

Also, try and set sniff to false (the default). When sniffing it turned on,
it will try to connect to the publish host of each node (its logged on each
node when it starts up), which might not be the IP you want to connect
through.

On Fri, Dec 23, 2011 at 1:51 AM, Shay Banon kim...@gmail.com wrote:

Transport client does not need the zen discovery settings to be applied to
it, since it does no discovery. It connects directly to the provided
servers. You can set org.elasticsearch.client.transport to TRACE level in
your logging configuration (on the client side) to see the failures it has
(to connect for example).

On Thu, Dec 22, 2011 at 11:44 PM, David Loehr dlo...@servicetask.comwrote:

I now have the two nodes communicating with each other, but am still
unable to access them through the Java API's TransportClient.

My servers are in Rackspace, and since multicast is disabled there, I
needed to use unicast to get them to discover each other:
discovery:
zen:
ping:
multicast:
enabled: false
unicast:
hosts: "server1:9300,server2:9300"

The second server to start now detects the other as the master, and
through curl, I can see that what I PUT to one, I can GET from the
other.

What settings do I need to use when setting up the TransportClient? Do
I need unicast here? I'm currently doing the following:

   Settings settings = ImmutableSettings.settingsBuilder()
       .put("cluster.name", "elasticsearch")
        .put("client.transport.sniff", true)
       .put("discovery.zen.ping.multicast.enabled", false)
       .put("discovery.zen.ping.unicast.enabled", true)
       .put("discovery.zen.ping.unicast.hosts",

"server1:9300,server2:9300")
.put("discovery.zen.multicast.enabled", false)
.put("discovery.zen.unicast.enabled", true)
.put("discovery.zen.unicast.hosts",
"server1:9300,server2:9300").build();
TransportClient client = new TransportClient(settings)
.addTransportAddress(new
InetSocketTransportAddress("server1", 9300))
.addTransportAddress(new
InetSocketTransportAddress("server2", 9300));
NodesInfoResponse rsp = client.admin().cluster().nodesInfo(new
NodesInfoRequest()).actionGet();
String str = "Cluster:" + rsp.getClusterName() + ". Active
nodes:";
str += rsp.getNodesMap().keySet();
renderText(str);

On Dec 22, 12:27 pm, David Loehr dlo...@servicetask.com wrote:

Hello,

I'm having trouble connecting to elasticsearch through the Java API. I
have two servers, each running Elasticsearch and my java application
(Play! Framework). I can connect to elasticsearch using curl on port
9200, for example:
$ curl -XGET server1:9200/_cluster/health

{"cluster_name":"elasticsearch","status":"yellow","timed_out":false,"number
_of_nodes":

1,"number_of_data_nodes":1,"active_primary_shards":5,"active_shards":
5,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":5}

But when I try to connect with the Java API on port 9300, I get a
NoNodeAvailableException. I've opened ports 9200 and 9300 on my
firewall. The ES log on each server, and the cluster health above,
seem to indicate that the two instances of Elasticsearch aren't
connecting to each other. I read in a few other threads that this is
often caused by mismatched cluster names, but I'm using the default
value, "elasticsearch".

What am I doing wrong?

Stack trace:
play.exceptions.JavaExecutionException: No node available
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
at Invocation.HTTP Request(Play!)
Caused by:
org.elasticsearch.client.transport.NoNodeAvailableException: No node
available
at

org.elasticsearch.client.transport.TransportClientNodesService.execute(Tran
sportClientNodesService.java:

  1. at

org.elasticsearch.client.transport.support.InternalTransportClusterAdminCli
ent.state(InternalTransportClusterAdminClient.java:

  1. at controllers.Search.index(Search.java:36)

/etc/elasticsearch/elasticsearch.yml config file (Elastic search is
set up as a service, as described athttp://
Elasticsearch Platform — Find real-time answers at scale | Elastic...
cluster:
name: elasticsearch
network:
host: eth1:ipv4

Elastic Search logs:
Server 1:
[2011-12-22 16:47:25,350][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: initializing ...
[2011-12-22 16:47:25,365][INFO ][plugins ] [Fight-
Man] loaded , sites
[2011-12-22 16:47:28,228][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: initialized
[2011-12-22 16:47:28,229][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: starting ...
[2011-12-22 16:47:28,324][INFO ][transport ] [Fight-
Man] bound_address {inet[/10.182.35.60:9300]}, publish_address {inet[/
10.182.1.2:9300]}
[2011-12-22 16:47:31,369][INFO ][cluster.service ] [Fight-
Man] new_master [Fight-Man][D_A18QcATlaFPE28FI5-gg][inet[/
10.182.1.2:9300]], reason: zen-disco-join (elected_as_master)
[2011-12-22 16:47:31,444][INFO ][discovery ] [Fight-
Man] elasticsearch/D_A18QcATlaFPE28FI5-gg
[2011-12-22 16:47:31,678][INFO ][http ] [Fight-
Man] bound_address {inet[/10.182.35.60:9200]}, publish_address {inet[/
10.182.1.2:9200]}
[2011-12-22 16:47:31,679][INFO ][node ] [Fight-
Man] {0.18.6}[1605]: started
[2011-12-22 16:47:32,393][INFO ][gateway ] [Fight-
Man] recovered [1] indices into cluster_state

Server 2:
[2011-12-22 16:52:10,402][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: initializing ...
[2011-12-22 16:52:10,411][INFO ][plugins ] [Jack-in-
the-Box] loaded , sites
[2011-12-22 16:52:13,505][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: initialized
[2011-12-22 16:52:13,507][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: starting ...
[2011-12-22 16:52:13,659][INFO ][transport ] [Jack-in-
the-Box] bound_address {inet[/10.182.33.113:9300]}, publish_address
{inet[/10.182.3.4:9300]}
[2011-12-22 16:52:16,815][INFO ][cluster.service ] [Jack-in-
the-Box] new_master [Jack-in-the-Box][tCfshMH-Q1KbsK6eYUTthw][inet[/
10.182.3.4:9300]], reason: zen-disco-join (elected_as_master)
[2011-12-22 16:52:16,857][INFO ][discovery ] [Jack-in-
the-Box] elasticsearch/tCfshMH-Q1KbsK6eYUTthw
[2011-12-22 16:52:16,950][INFO ][http ] [Jack-in-
the-Box] bound_address {inet[/10.182.33.113:9200]}, publish_address
{inet[/10.182.3.4:9200]}
[2011-12-22 16:52:16,953][INFO ][node ] [Jack-in-
the-Box] {0.18.6}[1799]: started
[2011-12-22 16:52:16,967][INFO ][gateway ] [Jack-in-
the-Box] recovered [0] indices into cluster_state

My Java code:
public class Search extends Controller {

@Get("/cluster")
public static void index() {
    Settings settings = ImmutableSettings.settingsBuilder()
        .put("cluster.name", "elasticsearch").build();
    TransportClient client = new TransportClient(settings)
        .addTransportAddress(new

InetSocketTransportAddress("10.182.1.2", 9300))
.addTransportAddress(new
InetSocketTransportAddress("10.182.3.4", 9300));
ActionFuture response =
client.admin().cluster().state(new ClusterStateRequest()); // Throws
exception
renderText(response.actionGet().getClusterName().toString());
}

@Get("/cluster/node")
public static void node() {
    Node node = nodeBuilder().data(false).node();
    Client client = node.client();
    ActionFuture<ClusterStateResponse> response =

client.admin().cluster().state(new ClusterStateRequest());

renderText(response.actionGet().state().getNodes().dataNodes().keySet()); //

Output is
}

}

iptables rules:
ACCEPT tcp -- server1 anywhere tcp dpt:9200
ACCEPT tcp -- server2 anywhere tcp dpt:9200
ACCEPT udp -- server1 anywhere udp dpt:9300
ACCEPT udp -- server2 anywhere udp dpt:9300
ACCEPT tcp -- server1 anywhere tcp dpt:9300
ACCEPT tcp -- server2 anywhere tcp dpt:9300