# Getting cluster blocked exception because of node started listen before join into cluster

**URL:** <https://discuss.elastic.co/t/getting-cluster-blocked-exception-because-of-node-started-listen-before-join-into-cluster/63345>\
**Category:** Elasticsearch\
**Created:** [October 19, 2016, 5:57am UTC](https://discuss.elastic.co/t/getting-cluster-blocked-exception-because-of-node-started-listen-before-join-into-cluster/63345 "2016-10-19T05:57:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Selvam\_ayyanar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/selvam_ayyanar/32/11101_2.png) [@Selvam\_ayyanar](https://discuss.elastic.co/u/Selvam_ayyanar)\
**Post date:** [October 19, 2016, 5:57am UTC](https://discuss.elastic.co/t/getting-cluster-blocked-exception-because-of-node-started-listen-before-join-into-cluster/63345/1 "2016-10-19T05:57:22Z")

</div>

Hi All,

Today we got Below exception in webapp layer ( jboss )  
**[SERVICE\_UNAVAILABLE/1/state not recovered / initialized];[SERVICE\_UNAVAILABLE/2/no master];**

we are using elasticsearch.jar ( transport client ) to connect es from jboss.  
elasticsearch version is 1.3.7

1. We initiated the start command at **2016-10-18 17:52:04,263**

2. Node started to listen at  
**[2016-10-18 17:52:06,491]**[INFO][transport] [node1] bound\_address {inet[/XX.XX.XX.XX:YYYY]}, publish\_address {inet[/XX.XX.XX.XX:YYYY]}

3. we got exception at  
**2016-10-18 17:52:08,753** 😓

4. Node Joined the cluster at  
**[2016-10-18 17:52:09,611]**[INFO][cluster.service] [node1] detected\_master

Is there any to avoid the listen before the added into cluster.  
[or]  
How to make the node to listen req after join the cluster

Please help on this!!!

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [October 19, 2016, 12:20pm UTC](https://discuss.elastic.co/t/getting-cluster-blocked-exception-because-of-node-started-listen-before-join-into-cluster/63345/2 "2016-10-19T12:20:44Z")

</div>

Hi @Selvam_ayyanar,

when did this problem happen (start of the appliation)? Can you show some code? Did you do anything on Elasticsearch side?

Daniel

---

<div class="post-metadata">

**Author:** ![Selvam\_ayyanar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/selvam_ayyanar/32/11101_2.png) [@Selvam\_ayyanar](https://discuss.elastic.co/u/Selvam_ayyanar)\
**Post date:** [October 19, 2016, 1:05pm UTC](https://discuss.elastic.co/t/getting-cluster-blocked-exception-because-of-node-started-listen-before-join-into-cluster/63345/3 "2016-10-19T13:05:49Z")

</div>

Hi @danielmitterdorfer

Thanks for the reply

This exception happen in-between the node startup and node joins the cluster.

> from application we tried to index a document, after joining cluster it is fine.  
> also after stopping node it is able to perform index operation on another node( using sniff )

> when we bring back the node, it throws the exception before the node joins into the cluster

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [October 19, 2016, 1:25pm UTC](https://discuss.elastic.co/t/getting-cluster-blocked-exception-because-of-node-started-listen-before-join-into-cluster/63345/4 "2016-10-19T13:25:27Z")

</div>

Hi @Selvam_ayyanar,

> [@Selvam\_ayyanar](#):
>
> This exception happen in-between the node startup and node joins the cluster.

by "node" you refer to your application in JBoss that is connected via the transport client to your Elasticsearch cluster?

Daniel

---

<div class="post-metadata">

**Author:** ![Selvam\_ayyanar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/selvam_ayyanar/32/11101_2.png) [@Selvam\_ayyanar](https://discuss.elastic.co/u/Selvam_ayyanar)\
**Post date:** [October 19, 2016, 1:26pm UTC](https://discuss.elastic.co/t/getting-cluster-blocked-exception-because-of-node-started-listen-before-join-into-cluster/63345/5 "2016-10-19T13:26:20Z")

</div>

hi @danielmitterdorfer

the node = elasticsearch instance

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [October 19, 2016, 1:44pm UTC](https://discuss.elastic.co/t/getting-cluster-blocked-exception-because-of-node-started-listen-before-join-into-cluster/63345/6 "2016-10-19T13:44:54Z")

</div>

Hi @Selvam_ayyanar,

can you paste the exception trace that you got?

Daniel

---

<div class="post-metadata">

**Author:** ![Selvam\_ayyanar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/selvam_ayyanar/32/11101_2.png) [@Selvam\_ayyanar](https://discuss.elastic.co/u/Selvam_ayyanar)\
**Post date:** [October 19, 2016, 2:15pm UTC](https://discuss.elastic.co/t/getting-cluster-blocked-exception-because-of-node-started-listen-before-join-into-cluster/63345/7 "2016-10-19T14:15:56Z")

</div>

Hi @danielmitterdorfer

below the exception we got from jboss

org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:745) Caused by: org.elasticsearch.cluster.block.ClusterBlockException: blocked by: **[SERVICE\_UNAVAILABLE/1/state not recovered / initialized];[SERVICE\_UNAVAILABLE/2/no master]**; at org.elasticsearch.cluster.block.ClusterBlocks.globalBlockedException(ClusterBlocks.java:138) at org.elasticsearch.action.count.TransportCountAction.checkGlobalBlock(TransportCountAction.java:128) at org.elasticsearch.action.count.TransportCountAction.checkGlobalBlock(TransportCountAction.java:64)

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [October 19, 2016, 2:21pm UTC](https://discuss.elastic.co/t/getting-cluster-blocked-exception-because-of-node-started-listen-before-join-into-cluster/63345/8 "2016-10-19T14:21:35Z")

</div>

Hi @Selvam_ayyanar,

great, exactly what I had expected. You just need to catch `ClusterBlockException`, check if it is retrieable and then do so. A very rough sketch (untested but I hope you get the idea):

```auto
int numberOfRetries = 3;
while (numberOfRetries > 0) {
    try {
        return client.doSomeAction();
    } catch (ClusterBlockException ex) {
        if (ex.retryable()) {
            numberOfRetries--;
            // wait a bit with the next retry
            Thread.sleep(1000L);
        } else {
            //not retryable -> bail
            throw ex;
        }
    }
}

```

Edit: I figured you should also wait a little bit between retries. 🙂

Daniel

---

<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:** [July 5, 2017, 10:11pm UTC](https://discuss.elastic.co/t/getting-cluster-blocked-exception-because-of-node-started-listen-before-join-into-cluster/63345/9 "2017-07-05T22:11:02Z")

</div>


