NEST: Performing retries with a single node

I am using NEST to perform queries towards an Elasticsearch 6-cluster. The Elasticsearch cluster consists of a couple of nodes, but it's running behind a firewall/loadbalancer so from the client perspective it appears as a single node with a single host name.

When new versions of my application are deployed, there are short network interruptions due to how the infrastructure/network works when it comes to blue-green deployments.

Since I only have a single Elasticsearch URI, NEST will use a SingleNodeConnectionPool instance when I create the connection. I have read in the documentation that with when this is the case, NEST won't perform any retries.

But in my case, I want to perform retries to handle the above network interruptions, since it's currently causes errors to be propagated to end-users. I understand i could implement rerty logic myself, but I was wondering if there's some way to get retry logic for network connection errors even when using SingleNodeConnectionPool.

The error I'm getting in my code is:

System.Net.Sockets.SocketException: 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 <server-ip>:<server-port>

Hello Knafve

I made some examples of queries on github using NEST in .net core, take a look there if it helps: GitHub - hgmauri/elasticsearch-with-nest: Example of using Elasticsearch in Docker with the NEST and Serilog nuget package in .NET 7.0

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