I'm trying to create documents in Elastic with the .Net client. (7.17.1 on server 8.1.3)
This works, but on the first sync I have many documents and after a lot of successul inserts the elastic client stops working.
I create the client like this only once:
var node = new Uri(config.ElasticHost);
var pool = new SingleNodeConnectionPool(node);
var elasticSettings = new ConnectionSettings(pool)
.CertificateFingerprint(config.ElasticFingerprint)
.BasicAuthentication(config.ElasticUser, config.ElasticPassword)
.DefaultMappingFor...
.EnableDebugMode()
.PrettyJson();
_elasticClient = new ElasticClient(elasticSettings);
Then for each new document I use this:
private async Task<bool> UpdateOrInsert<T>(T item) where T : ElasticDocument
{
var response = await _elasticClient.IndexDocumentAsync<T>(item);
if (!response.IsValid)
{
_logger.LogError(response.OriginalException.Message);
_logger.LogError(response.DebugInformation);
return false;
}
return true;
}
After a while I get the error below.
What could cause this? The server is not broken after this. I can just connect again.
Seems like the client stops working after a while?
Invalid NEST response built from a unsuccessful () low level call on PUT: /productlink-dev/_doc/LC-7-1085-DUMMY_1201G6302000_ST30?pretty=true&error_trace=true
# Audit trail of this API call:
- [1] BadRequest: Node: https://xx.xx.xx.xx:9200/ Took: 00:00:19.2788193
# OriginalException: System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
---> System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
--- End of inner exception stack trace ---
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
at System.Net.Security.SslStream.EnsureFullTlsFrameAsync[TIOAdapter](TIOAdapter adapter)
at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](TIOAdapter adapter, Memory`1 buffer)
at System.Net.Http.HttpConnection.InitialFillAsync(Boolean async)
at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at Elasticsearch.Net.HttpConnection.RequestAsync[TResponse](RequestData requestData, CancellationToken cancellationToken)
# Request:
{stripped}
# Response:
# TCP states:
Established: 323
TimeWait: 7
CloseWait: 1
# ThreadPool statistics:
Worker:
Busy: 1
Free: 32766
Min: 16
Max: 32767
IOCP:
Busy: 1
Free: 999
Min: 16
Max: 1000
Update:
I tried with BulkAll but now I get Invalid documents without an error.