Need clatification on "TransportException"

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?

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

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.

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.

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();
    }