Java api errors versus basic gets working fine

Hey All,
I think this has got to be not setting up the Java API correctly.
Have a box in ec2 that is running elasticsearch.
locally, can get cluster status and health, and docs, etc.
my my local dev, connecting to that box, using a basic get
I can get cluster health/status, add docs, etc.

basically, I make a Java URL and do a get:
(hacked example):
URL urlPage = new URL(strUrl);

    HttpURLConnection urlConnection =

(HttpURLConnection)urlPage.openConnection();

However, when I try doing the same things with a TransportClient, I
just hang there (if I use port 9200) or get No Node available (if I
used port 9300)

Help on the transportclient setup would be much appreciated, because
all other methods of connecting seem to work fine.

-code snippet-
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "cluster2")
.put("client.transport.sniff", true).build();

    TransportClient client = new TransportClient(settings);


    client.addTransportAddress( new

InetSocketTransportAddress("", <tried 9200 and
9300 here>));

right here is where it fails. it either hangs (port 9200)
or, responds with "No Node Available" using port 9300

any ideas?

Using TransportClient, you should use port 9300, not 9200. If you talk
remotely to an ec2 instance, you might not want to set sniff to true, this
is because the publish address of the node might be the private IP, while
you want to connect over the public IP (when sniff is set to true, the node
publish IP is used to talk to it). Also, is port 9300 open?

On Wed, Oct 5, 2011 at 1:52 AM, Scott Decker scott@publishthis.com wrote:

Hey All,
I think this has got to be not setting up the Java API correctly.
Have a box in ec2 that is running elasticsearch.
locally, can get cluster status and health, and docs, etc.
my my local dev, connecting to that box, using a basic get
I can get cluster health/status, add docs, etc.

basically, I make a Java URL and do a get:
(hacked example):
URL urlPage = new URL(strUrl);

   HttpURLConnection urlConnection =

(HttpURLConnection)urlPage.openConnection();

However, when I try doing the same things with a TransportClient, I
just hang there (if I use port 9200) or get No Node available (if I
used port 9300)

Help on the transportclient setup would be much appreciated, because
all other methods of connecting seem to work fine.

-code snippet-
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "cluster2")
.put("client.transport.sniff", true).build();

   TransportClient client = new TransportClient(settings);


   client.addTransportAddress( new

InetSocketTransportAddress("", <tried 9200 and
9300 here>));

right here is where it fails. it either hangs (port 9200)
or, responds with "No Node Available" using port 9300

any ideas?

Ahh, here is some info, in case anyone searches the groups looking for
a similar answer.

Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "").build();

does the trick.

yes, port 9300 also needs to be used when setting up the
transportclient.

here was the last one.

when building and getting the clusterhealthrequest
i had this, which is what the javadoc said you could do:
ClusterHealthRequest chr =
Requests.clusterHealthRequest((String)null);

however, that causes a nullpointerexception in some .writeUTF

if you change it to:
ClusterHealthRequest chr = Requests.clusterHealthRequest("");

then it works fine and the request will then work.

Thanks for the help on this Shay

On Oct 5, 2:57 am, Shay Banon kim...@gmail.com wrote:

Using TransportClient, you should use port 9300, not 9200. If you talk
remotely to an ec2 instance, you might not want to set sniff to true, this
is because the publish address of the node might be the private IP, while
you want to connect over the public IP (when sniff is set to true, the node
publish IP is used to talk to it). Also, is port 9300 open?

On Wed, Oct 5, 2011 at 1:52 AM, Scott Decker sc...@publishthis.com wrote:

Hey All,
I think this has got to be not setting up the Java API correctly.
Have a box in ec2 that is running elasticsearch.
locally, can get cluster status and health, and docs, etc.
my my local dev, connecting to that box, using a basic get
I can get cluster health/status, add docs, etc.

basically, I make a Java URL and do a get:
(hacked example):
URL urlPage = new URL(strUrl);

   HttpURLConnection urlConnection =

(HttpURLConnection)urlPage.openConnection();

However, when I try doing the same things with a TransportClient, I
just hang there (if I use port 9200) or get No Node available (if I
used port 9300)

Help on the transportclient setup would be much appreciated, because
all other methods of connecting seem to work fine.

-code snippet-
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "cluster2")
.put("client.transport.sniff", true).build();

   TransportClient client = new TransportClient(settings);
   client.addTransportAddress( new

InetSocketTransportAddress("", <tried 9200 and
9300 here>));

right here is where it fails. it either hangs (port 9200)
or, responds with "No Node Available" using port 9300

any ideas?

Just don't pass anything in the health request parameter. For example:

client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();

On Wed, Oct 5, 2011 at 7:10 PM, Scott Decker scott@publishthis.com wrote:

Ahh, here is some info, in case anyone searches the groups looking for
a similar answer.

Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "").build();

does the trick.

yes, port 9300 also needs to be used when setting up the
transportclient.

here was the last one.

when building and getting the clusterhealthrequest
i had this, which is what the javadoc said you could do:
ClusterHealthRequest chr =
Requests.clusterHealthRequest((String)null);

however, that causes a nullpointerexception in some .writeUTF

if you change it to:
ClusterHealthRequest chr = Requests.clusterHealthRequest("");

then it works fine and the request will then work.

Thanks for the help on this Shay

On Oct 5, 2:57 am, Shay Banon kim...@gmail.com wrote:

Using TransportClient, you should use port 9300, not 9200. If you talk
remotely to an ec2 instance, you might not want to set sniff to true,
this
is because the publish address of the node might be the private IP, while
you want to connect over the public IP (when sniff is set to true, the
node
publish IP is used to talk to it). Also, is port 9300 open?

On Wed, Oct 5, 2011 at 1:52 AM, Scott Decker sc...@publishthis.com
wrote:

Hey All,
I think this has got to be not setting up the Java API correctly.
Have a box in ec2 that is running elasticsearch.
locally, can get cluster status and health, and docs, etc.
my my local dev, connecting to that box, using a basic get
I can get cluster health/status, add docs, etc.

basically, I make a Java URL and do a get:
(hacked example):
URL urlPage = new URL(strUrl);

   HttpURLConnection urlConnection =

(HttpURLConnection)urlPage.openConnection();

However, when I try doing the same things with a TransportClient, I
just hang there (if I use port 9200) or get No Node available (if I
used port 9300)

Help on the transportclient setup would be much appreciated, because
all other methods of connecting seem to work fine.

-code snippet-
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "cluster2")
.put("client.transport.sniff", true).build();

   TransportClient client = new TransportClient(settings);
   client.addTransportAddress( new

InetSocketTransportAddress("", <tried 9200 and
9300 here>));

right here is where it fails. it either hangs (port 9200)
or, responds with "No Node Available" using port 9300

any ideas?