# NoNodeAvailableException happening when connecting to cluster deployed on GCP

**URL:** <https://discuss.elastic.co/t/nonodeavailableexception-happening-when-connecting-to-cluster-deployed-on-gcp/85312>\
**Category:** Elasticsearch\
**Created:** [May 10, 2017, 9:36pm UTC](https://discuss.elastic.co/t/nonodeavailableexception-happening-when-connecting-to-cluster-deployed-on-gcp/85312 "2017-05-10T21:36:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rohit\_Nigam](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@Rohit\_Nigam](https://discuss.elastic.co/u/Rohit_Nigam)\
**Post date:** [May 10, 2017, 9:36pm UTC](https://discuss.elastic.co/t/nonodeavailableexception-happening-when-connecting-to-cluster-deployed-on-gcp/85312/1 "2017-05-10T21:36:21Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 11, 2017, 5:03am UTC](https://discuss.elastic.co/t/nonodeavailableexception-happening-when-connecting-to-cluster-deployed-on-gcp/85312/2 "2017-05-11T05:03:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Rohit\_Nigam](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@Rohit\_Nigam](https://discuss.elastic.co/u/Rohit_Nigam)\
**Post date:** [May 11, 2017, 5:21am UTC](https://discuss.elastic.co/t/nonodeavailableexception-happening-when-connecting-to-cluster-deployed-on-gcp/85312/3 "2017-05-11T05:21:26Z")

</div>

I tried it  
  
org.elasticsearch  
elasticsearch  
2.4.2

Settings settings = Settings.builder()  
.put("[cluster.name](http://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

---

<div class="post-metadata">

**Author:** ![Rohit\_Nigam](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@Rohit\_Nigam](https://discuss.elastic.co/u/Rohit_Nigam)\
**Post date:** [May 11, 2017, 5:27am UTC](https://discuss.elastic.co/t/nonodeavailableexception-happening-when-connecting-to-cluster-deployed-on-gcp/85312/4 "2017-05-11T05:27:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 11, 2017, 5:50am UTC](https://discuss.elastic.co/t/nonodeavailableexception-happening-when-connecting-to-cluster-deployed-on-gcp/85312/5 "2017-05-11T05:50:03Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). 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?

---

<div class="post-metadata">

**Author:** ![Rohit\_Nigam](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@Rohit\_Nigam](https://discuss.elastic.co/u/Rohit_Nigam)\
**Post date:** [May 11, 2017, 6:10am UTC](https://discuss.elastic.co/t/nonodeavailableexception-happening-when-connecting-to-cluster-deployed-on-gcp/85312/6 "2017-05-11T06:10:01Z")

</div>

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}]]

```auto
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));
          

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 11, 2017, 6:24am UTC](https://discuss.elastic.co/t/nonodeavailableexception-happening-when-connecting-to-cluster-deployed-on-gcp/85312/7 "2017-05-11T06:24:53Z")

</div>

**Please format your code** using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 8, 2017, 6:38am UTC](https://discuss.elastic.co/t/nonodeavailableexception-happening-when-connecting-to-cluster-deployed-on-gcp/85312/8 "2017-06-08T06:38:46Z")

</div>

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