NoNodeAvailableException happening when connecting to cluster deployed on GCP

Hi
I did a one click deployment of elastic search cluster on Google cloud. It is using 2.4.4 version of elastic search and i am using 5.4.0 version in pom.xml

org.elasticsearch.client
transport
5.4.0
I keep on getting NoNodeAvailableException always. I am doing Post call and here is the code for that.

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
LOG.info("Entered doPost");
String urlPath = req.getPathInfo();
String id = urlPath.split("/")[1];

if(StringUtils.isNotBlank(id)) {
    LOG.info("Reached here");
    Settings settings = Settings.builder()
            .put("cluster.name", "elasticsearch-cluster")
            .put("client.transport.sniff",true)
            .build();

    Client client = new PreBuiltTransportClient(settings)
            .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xx.xx.xx.10"), 9300))
            .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xx.xx.xx.11"), 9300))
            .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xx.xx.xx.12"), 9300));

   try {

        if (req.getInputStream() != null) {

            BufferedReader in = new BufferedReader(
                    new InputStreamReader(req.getInputStream()));
            String inputLine;
            StringBuffer sdf = new StringBuffer();
            while ((inputLine = in.readLine()) != null) {
                sdf.append(inputLine);
            }
            in.close();
            String json = sdf.toString();
            if (StringUtils.isNotBlank(json)) {
                IndexResponse response = client.prepareIndex("twitter","tweet",id).setSource(json).execute().actionGet();

//

                // Index name
                String _index = response.getIndex();

// Type name
String _type = response.getType();
// Document ID (generated or not)
String _id = response.getId();
// Version (if it's the first time you index this document, you will get: 1)
long _version = response.getVersion();
// status has stored current instance statement.
RestStatus status = response.status();

                Response response1 = Response.builder().index(_index).type1(_type).version(_version).id(_id).status(status).build();
                String ress = new Gson().toJson(response1);
                LOG.info("*****ress***** " + ress);
                if (StringUtils.isNotBlank(ress)) {
                    LOG.info("response " + ress);
                    resp.setStatus(HttpServletResponse.SC_CREATED);
                    PrintWriter out = resp.getWriter();
                    out.println(ress);
                    out.close();
                    out.flush();
                    resp.getWriter().close();
                }
            }


        }
    } catch (Exception e) {
        e.printStackTrace();

    }
    client.close();
}

Your help would really appreciated.
Regards
Rohit

It won't work. You need to use the transport client 2.4 instead.

I tried it

org.elasticsearch
elasticsearch
2.4.2

Settings settings = Settings.builder()
.put("cluster.name", "elasticsearch1-cluster")
.put("client.transport.sniff",true)
.build();
TransportClient client = TransportClient.builder().build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xx.xx.xx.9"), 9300))
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xx.xx.xx.10"), 9300))
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xx.xx.xx.11"), 9300));

But it is again throwing the same error at this line
IndexResponse response = client.prepareIndex("twitter","tweet",id).setSource(json).execute().actionGet();

Not sure what else i need to do?

Regards
Rohit

May be i will try 2.4.0 instead of 2.4.2 and see if it works.

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

Some ideas:

  • firewall?
  • elasticsearch is not bound to xx.xx.xx.9

May be share with us one of your elasticsearch node logs?

Hi
I tried with 2.4 client and still getting the exception. Pasting the logs from GCP console running the google flex appengine... firewalls are open for tcp:0-65535;udp:0-65535;icmp

A at java.lang.Thread.run(Thread.java:745)

A at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)

A at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)

A at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)

A at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)

A at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)

A at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)

A at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)

A at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)

A at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:306)

A at org.eclipse.jetty.server.Server.handle(Server.java:517)

A at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)

A at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)

A at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)

A at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)

A at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)

A at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)

A at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)

A at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)

A at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)

A at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)

A at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)

A at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)

A at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821)

A at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)

A at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)

A at com.example.endpoints.SearchServlet.doPost(SearchServlet.java:179)

A at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:64)

A at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56)

A at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86)

A at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359)

A at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:288)

A at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)

A at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:207)

A at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:290)

A NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{xx.xx.x.9}{xx.xx.x.9:9300}, {#transport#-2}{xx.xx.x.10}{xx.xx.x.10:9300}, {#transport#-3}{xx.xx.x.11}{xx.xx.x.11:9300}]]

Settings settings = Settings.builder()
                    .put("cluster.name", "elasticsearch-cluster")
                    .put("client.transport.sniff",true)
                    .build();
            TransportClient client = TransportClient.builder().build()
                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xx.xx.x.9"), 9300))
                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xx.xx.x.10"), 9300))
                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xx.xx.x.11"), 9300));
          

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

I asked for elasticsearch logs. Can you share them please?

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