# Using NEST (.NET client) with Elastic Cloud

**URL:** <https://discuss.elastic.co/t/using-nest-net-client-with-elastic-cloud/144240>\
**Category:** Elasticsearch\
**Created:** [August 13, 2018, 9:21pm UTC](https://discuss.elastic.co/t/using-nest-net-client-with-elastic-cloud/144240 "2018-08-13T21:21:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tmenier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tmenier/32/34447_2.png) [@tmenier](https://discuss.elastic.co/u/tmenier)\
**Post date:** [August 13, 2018, 9:21pm UTC](https://discuss.elastic.co/t/using-nest-net-client-with-elastic-cloud/144240/1 "2018-08-13T21:21:46Z")

</div>

I'm connecting to an Elastic Cloud deployment of Elasticsearch with the NEST client for .NET. The deployment is based on the default "I/O Optimized" template. It has a single "instance", but 2 "zones." I am assuming that this means one "node", and therefore out of the various [NEST connection pool options](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/connection-pooling.html), I should use **SingleNodeConnectionPool**. Is that correct? "Zones" are a lower-level failover concern and I only ever need to connect to 1 endpoint?

---

<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:** [August 14, 2018, 12:30am UTC](https://discuss.elastic.co/t/using-nest-net-client-with-elastic-cloud/144240/2 "2018-08-14T00:30:50Z")

</div>

You should use the `SingleNodeConnectionPool` with Elastic Cloud; the cluster is behind a proxy so the other connection pools like `StaticConnectionPool` and `SniffingConnectionPool` won't work as expected.

---

<div class="post-metadata">

**Author:** ![tmenier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tmenier/32/34447_2.png) [@tmenier](https://discuss.elastic.co/u/tmenier)\
**Post date:** [August 14, 2018, 3:26pm UTC](https://discuss.elastic.co/t/using-nest-net-client-with-elastic-cloud/144240/3 "2018-08-14T15:26:05Z")

</div>

Thanks Russ, you seem to answer my questions wherever I ask them 🙂. Appreciate the help!

---

<div class="post-metadata">

**Author:** ![Spyros\_Giannopoulos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spyros_giannopoulos/32/82772_2.png) [@Spyros\_Giannopoulos](https://discuss.elastic.co/u/Spyros_Giannopoulos)\
**Post date:** [August 20, 2018, 2:02pm UTC](https://discuss.elastic.co/t/using-nest-net-client-with-elastic-cloud/144240/4 "2018-08-20T14:02:59Z")

</div>

Could you please elaborate a bit more why StaticConnectionPool is not working as it should. I have tried it several times and it worked. Did I was lucky somehow?

I understand that StaticConnectionPool runs pings but haven't faced any issues yet with that. Should I worry though?

---

<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:** [August 22, 2018, 12:40am UTC](https://discuss.elastic.co/t/using-nest-net-client-with-elastic-cloud/144240/5 "2018-08-22T00:40:36Z")

</div>

@Spyros_Giannopoulos I should have been more specific 😄

- `SniffingConnectionPool` will not work as expected, because the client uses the `Uri`s it's seeded with to make a _sniff request_ to the cluster to find all the nodes in the cluster, using the `publish_address` (or first `bound_address` when `publish_address` is not set) returned as the address use to communicate with a node. The addresses returned for nodes are not publicly reachable however, so this pool should not be used.

- `StaticConnectionPool` _will work_, as it does not issue a _sniff request_ to find all nodes in the cluster. Instead, it will use the `Uri`s that it is seeded with to make requests. In using the `StaticConnectionPool` over `SingleNodeConnectionPool` however, you pay a _small_ performance cost associated with the internal implementation round-robin'ing over nodes to select one to issue the request against, in addition to logic that marks nodes as _dead_ and _resurrects_ them after a certain period of time.

So, in the case of Elastic Cloud, or any scenario where the cluster is behind a single endpoint, the best [connection pool](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/connection-pooling.html) to use is `SingleNodeConnectionPool`.

---

<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:** [September 19, 2018, 12:54am UTC](https://discuss.elastic.co/t/using-nest-net-client-with-elastic-cloud/144240/6 "2018-09-19T00:54:57Z")

</div>

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