# Need clatification on "TransportException"

**URL:** <https://discuss.elastic.co/t/need-clatification-on-transportexception/24015>\
**Category:** Elasticsearch\
**Created:** [June 19, 2015, 8:05pm UTC](https://discuss.elastic.co/t/need-clatification-on-transportexception/24015 "2015-06-19T20:05:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![subramaniajeeva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subramaniajeeva/32/656_2.png) [@subramaniajeeva](https://discuss.elastic.co/u/subramaniajeeva)\
**Post date:** [June 19, 2015, 8:05pm UTC](https://discuss.elastic.co/t/need-clatification-on-transportexception/24015/1 "2015-06-19T20:05:18Z")

</div>

I'm writing a elastic search wrapper for our application. I'm doing disruptive testing by taking a node down and similar things, so that I can do retry on the basis of the exception type.

I'm getting TransportException "TransportService is closed stopped can't send request". Also I'm using Transport client to connect to elastic search.

Not sure when will this happen. I need some clarification on this exception.

Also I need help on possible exceptions which can happen while doing disruptive testing.

Can anyone help me with the same?

---

<div class="post-metadata">

**Author:** ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)\
**Post date:** [June 19, 2015, 11:44pm UTC](https://discuss.elastic.co/t/need-clatification-on-transportexception/24015/2 "2015-06-19T23:44:05Z")

</div>

> [@subramaniajeeva](#):
>
> disruptive testing by taking a node down

what nodes was that? client node or one of the cluster node?

from the exception, it looks like the client node been taken down that gave the exception.

```
        clientHandlers.put(requestId, new RequestHolder<>(handler, node, action, timeoutHandler));
        if (started.get() == false) {
            // if we are not started the exception handling will remove the RequestHolder again and calls the handler to notify the caller.
            // it will only notify if the toStop code hasn't done the work yet.
            throw new TransportException("TransportService is closed stopped can't send request");
        }

```

hth

---

<div class="post-metadata">

**Author:** ![subramaniajeeva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subramaniajeeva/32/656_2.png) [@subramaniajeeva](https://discuss.elastic.co/u/subramaniajeeva)\
**Post date:** [June 20, 2015, 5:57pm UTC](https://discuss.elastic.co/t/need-clatification-on-transportexception/24015/3 "2015-06-20T17:57:39Z")

</div>

I took down the master node from cluster, while client was sending request.

This is my configuration: I have 6 nodes in cluster in which one of them is master.

---

<div class="post-metadata">

**Author:** ![terrasacer](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@terrasacer](https://discuss.elastic.co/u/terrasacer)\
**Post date:** [February 11, 2016, 11:06pm UTC](https://discuss.elastic.co/t/need-clatification-on-transportexception/24015/4 "2016-02-11T23:06:08Z")

</div>

Hi guys.

I have similar problem. My simple code is as follow

```
node = NodeBuilder.nodeBuilder()
        .settings(Settings.settingsBuilder()
        .put("http.enabled", false)
        .put("path.home", "/Users/my_home/Desktop")
        .build())
        .client(false)
        .node();
client = node.client();

//index operations

node.close();

```

The index operations are successful but I get an error when I close the node.

```
Feb 12, 2016 12:33:51 AM org.elasticsearch.cluster.action.shard.ShardStateAction$2 handleException
WARNING: [Pyro] failed to send shard started to [{Pyro}{ud9W86hCQ5OEWJ9FCCHQIQ}{127.0.0.1}{127.0.0.1:9300}]
SendRequestTransportException[[Pyro][127.0.0.1:9300][internal:cluster/shard/started]]; nested: TransportException[TransportService is closed stopped can't send request];
	at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:323)
	at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:282)
	at org.elasticsearch.cluster.action.shard.ShardStateAction.shardStarted(ShardStateAction.java:122)
	at org.elasticsearch.cluster.action.shard.ShardStateAction.shardStarted(ShardStateAction.java:116)
	at org.elasticsearch.indices.cluster.IndicesClusterStateService$2.onRecoveryDone(IndicesClusterStateService.java:639)
	at org.elasticsearch.index.shard.StoreRecoveryService$1.run(StoreRecoveryService.java:156)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: TransportException[TransportService is closed stopped can't send request]
	at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:303)
	... 8 more

```

I use version 2.2.0

```
<dependency>
          <groupId>org.elasticsearch</groupId>
          <artifactId>elasticsearch</artifactId>
          <version>${elastic.version}</version>
</dependency>

```

Thank you in advance for your answers.

---

<div class="post-metadata">

**Author:** ![fabioang](https://avatars.discourse-cdn.com/v4/letter/f/848f3c/32.png) [@fabioang](https://discuss.elastic.co/u/fabioang)\
**Post date:** [March 15, 2016, 1:36pm UTC](https://discuss.elastic.co/t/need-clatification-on-transportexception/24015/5 "2016-03-15T13:36:37Z")

</div>

I suggest you to wait for the green status after the node creation and to refresh the index before closing the node.

```
{
   // ... 
   client = node.client();
    waitForReady(client);
    //index operations
    
    refreshIndex(client,"index_name");
    node.close();
}
    public static void waitForReady(Client client) {
        // wait 30 seconds for yellow
        ClusterHealthRequest req = new ClusterHealthRequest().waitForYellowStatus();
        ClusterHealthResponse response = client.admin().cluster().health(req).actionGet(3000);
        if (response.getStatus() == ClusterHealthStatus.RED) {
            throw new RuntimeException("ElasticSearch cluster status failed become ready");
        }
    }

    public static void refreshIndex(Client client, String index) {
          RefreshRequest request = new RefreshRequest();
          request.indices(index);
          client.admin().indices().refresh(request).actionGet();
    }
```

---

<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, 11:08pm UTC](https://discuss.elastic.co/t/need-clatification-on-transportexception/24015/6 "2017-07-05T23:08:18Z")

</div>


