# Check if elasticsearch nodes are alive on startup using nest

**URL:** <https://discuss.elastic.co/t/check-if-elasticsearch-nodes-are-alive-on-startup-using-nest/99905>\
**Category:** Elasticsearch\
**Created:** [September 8, 2017, 9:37pm UTC](https://discuss.elastic.co/t/check-if-elasticsearch-nodes-are-alive-on-startup-using-nest/99905 "2017-09-08T21:37:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ESCoder](https://avatars.discourse-cdn.com/v4/letter/e/9e8a1a/32.png) [@ESCoder](https://discuss.elastic.co/u/ESCoder)\
**Post date:** [September 8, 2017, 9:37pm UTC](https://discuss.elastic.co/t/check-if-elasticsearch-nodes-are-alive-on-startup-using-nest/99905/1 "2017-09-08T21:37:30Z")

</div>

Hi,

I'm using Nest 5.x as a part of an application to communicate with ES. When my application starts up, the following code is executed

```
List<Node> nodes = new List<Node>();

nodes.AddRange(config.Nodes.Select(nodeUri => CreateNode(nodeUri)));

var connectionPool = new SniffingConnectionPool(nodes);
var settings = new ConnectionSettings(connectionPool);
    			
settings.DefaultFieldNameInferrer(p => p);

Nest.ElasticClient esClient = new Nest.ElasticClient(settings);

```

If my ES instance (nodeUri) is not up and running, the above code will not throw any exception during the startup, but when I actually try to index a document, then it throws an exception.

Is there any way I can ensure that nodes I'm trying to connect are active during start up itself?

Thanks

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [September 9, 2017, 11:38pm UTC](https://discuss.elastic.co/t/check-if-elasticsearch-nodes-are-alive-on-startup-using-nest/99905/2 "2017-09-09T23:38:41Z")

</div>

With `SniffingConnectionPool`

1. the state of the cluster is [sniffed on startup](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/sniffing-on-startup.html) and the pool of nodes that the client can use to make requests against is [reseeded](https://github.com/elastic/elasticsearch-net/blob/07d2c41e7f56816c882271e76ee4995732982391/src/Elasticsearch.Net/Transport/Pipeline/RequestPipeline.cs#L364-L364) with the nodes returned in the sniffing response.
2. [A node is pinged when it is used for the first time](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/ping-on-first-usage.html) as a quick way of ascertaining it is healthy.

So the default behaviour of the client with `SniffingConnectionPool` should already be doing what you'd like to do. Is this not what you're seeing? If not, what does the [audit trail](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/audit-trail.html) look like for indexing the document?

---

<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:** [October 7, 2017, 11:38pm UTC](https://discuss.elastic.co/t/check-if-elasticsearch-nodes-are-alive-on-startup-using-nest/99905/3 "2017-10-07T23:38:43Z")

</div>

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