# .NET NEST https error: The handshake failed due to an unexpected packet format

**URL:** <https://discuss.elastic.co/t/net-nest-https-error-the-handshake-failed-due-to-an-unexpected-packet-format/62982>\
**Category:** Elasticsearch\
**Created:** [October 13, 2016, 6:38pm UTC](https://discuss.elastic.co/t/net-nest-https-error-the-handshake-failed-due-to-an-unexpected-packet-format/62982 "2016-10-13T18:38:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [October 13, 2016, 6:38pm UTC](https://discuss.elastic.co/t/net-nest-https-error-the-handshake-failed-due-to-an-unexpected-packet-format/62982/1 "2016-10-13T18:38:05Z")

</div>

NEST 5.0-beta1

If I use https:// instead of http:// I get this error while indexing a doc.

```
var uri = new Uri("https://192.168.11.223:9200");
var settings = new ConnectionSettings(uri);
settings.BasicAuthentication("elastic", "xxx");
var elk = new ElasticClient(settings);

```

> Invalid NEST response built from a unsuccessful low level call on PUT: /backups-2016.10.13/jobhistory/5fe2a8ec-ecc8-4592-8221-77af67c02fbb\_7804
> 
> # Audit trail of this API call:
> 
> - [1] BadResponse: Node: [https://192.168.11.223:9200/](https://192.168.11.223:9200/) Took: 00:00:01.0036572
> 
> # OriginalException: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---\> System.IO.IOException: The handshake failed due to an unexpected packet format.
> 
> at System.Net.Security.SslState.StartReadFrame(Byte buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)  
> at System.Net.Security.SslState.StartReceiveBlob(Byte buffer, AsyncProtocolRequest asyncRequest)  
> at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)  
> at System.Net.Security.SslState.StartSendBlob(Byte incoming, Int32 count, AsyncProtocolRequest asyncRequest)  
> at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte buffer, AsyncProtocolRequest asyncRequest)  
> at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)  
> at System.Net.TlsStream.CallProcessAuthentication(Object state)  
> at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)  
> at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)  
> at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)  
> at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)  
> at System.Net.TlsStream.Write(Byte buffer, Int32 offset, Int32 size)  
> at System.Net.PooledStream.Write(Byte buffer, Int32 offset, Int32 size)  
> at System.Net.ConnectStream.WriteHeaders(Boolean async)  
> --- End of inner exception stack trace ---  
> at System.Net.HttpWebRequest.GetResponse()  
> at Elasticsearch.Net.HttpConnection.Request[TReturn](RequestData requestData) in C:\code\elasticsearch-net\src\Elasticsearch.Net\Connection\HttpConnection.cs:line 142
> 
> # Request:
> 
> \<Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.\>
> 
> # Response:
> 
> \<Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.\>

---

<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, 10:12pm UTC](https://discuss.elastic.co/t/net-nest-https-error-the-handshake-failed-due-to-an-unexpected-packet-format/62982/2 "2017-07-05T22:12:34Z")

</div>


