# Issue with NEST SniffingConnectionPool + TLS

**URL:** <https://discuss.elastic.co/t/issue-with-nest-sniffingconnectionpool-tls/106444>\
**Category:** Elasticsearch\
**Created:** [November 5, 2017, 8:04pm UTC](https://discuss.elastic.co/t/issue-with-nest-sniffingconnectionpool-tls/106444 "2017-11-05T20:04:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Illidan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/illidan/32/54264_2.png) [@Illidan](https://discuss.elastic.co/u/Illidan)\
**Post date:** [November 5, 2017, 8:04pm UTC](https://discuss.elastic.co/t/issue-with-nest-sniffingconnectionpool-tls/106444/1 "2017-11-05T20:04:49Z")

</div>

Trying to establish connection to my ES cluster over TLS.

When I using SniffingConnectionPool, I getting the following exception: "The handshake failed due to an unexpected packet format."

Trying to connect without it works fine.

Is that is a bug or I missing something?

---

<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:** [November 5, 2017, 10:21pm UTC](https://discuss.elastic.co/t/issue-with-nest-sniffingconnectionpool-tls/106444/2 "2017-11-05T22:21:34Z")

</div>

So you have an example of the requets you're making and the exception stack trace / [debug information](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/debug-information.html)?

---

<div class="post-metadata">

**Author:** ![Illidan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/illidan/32/54264_2.png) [@Illidan](https://discuss.elastic.co/u/Illidan)\
**Post date:** [November 17, 2017, 10:22am UTC](https://discuss.elastic.co/t/issue-with-nest-sniffingconnectionpool-tls/106444/3 "2017-11-17T10:22:59Z")

</div>

First call to NEST giving that exception. In my case, it was:

var isIndexExistsResponse = \_elasticClient.IndexExists(new IndexExistsRequest(IndexName));

---

<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:** [November 20, 2017, 5:02am UTC](https://discuss.elastic.co/t/issue-with-nest-sniffingconnectionpool-tls/106444/4 "2017-11-20T05:02:16Z")

</div>

Some further questions about your TLS setup:

1. How do you have SSL/TLS set up?
2. Are you using self-signed certs?
3. Are these generated using certgen?
4. Are they issued from a trusted Certificate Authority (CA)?

Take a look at the [working with certificates documentation for NEST.](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/working-with-certificates.html)

---

<div class="post-metadata">

**Author:** ![Illidan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/illidan/32/54264_2.png) [@Illidan](https://discuss.elastic.co/u/Illidan)\
**Post date:** [November 20, 2017, 6:28am UTC](https://discuss.elastic.co/t/issue-with-nest-sniffingconnectionpool-tls/106444/5 "2017-11-20T06:28:03Z")

</div>

Answering in the same order:

1. I put Nginx in the front of ES, and configured it for SSL (Nginx performs SSL termination).
2. No, I using standard LetsEncrypt certificates
3. No, I using standard LetsEncrypt certificates
4. Yes they are - I using standard LetsEncrypt certificates

BTW, when I switched to StaticConnectionPool - everything works fine (everything else exactly the same).

---

<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:** [November 20, 2017, 7:01am UTC](https://discuss.elastic.co/t/issue-with-nest-sniffingconnectionpool-tls/106444/6 "2017-11-20T07:01:41Z")

</div>

> [@Illidan](#):
>
> I put Nginx in the front of ES, and configured it for SSL (Nginx performs SSL termination).

That sounds like it's the likely cause; SniffingConnectionPool seeds itself on startup and at intervals with known nodes in the cluster, based on what is returned from `/_nodes/http,settings` API call.

Do nodes have TLS configured for the HTTP layer? Would it be possible to [capture what is returned from the first request](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/debug-information.html) with `.DisableDirectStreaming()` set on `ConnectionSettings`? It sounds like the client may not be handling this gracefully so any further detail that you can provide will help.

---

<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:** [December 18, 2017, 7:02am UTC](https://discuss.elastic.co/t/issue-with-nest-sniffingconnectionpool-tls/106444/7 "2017-12-18T07:02:02Z")

</div>

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