ThrowExceptions() and retries in Nest 6

We are using elasticsearch 6.2.0 and Nest 6.0.0.

We want to use SniffingConnectionPool with request retries. We have ThrowExceptions() enabled because we don't want to think abount handling exceptions.

We created test, in which we try to send request to node, that guaranteed to return 500 (NotEnoughMasterException). We expect to make retry to another node. However it fails with exception:

Elasticsearch.Net.PipelineException: Failed sniffing cluster state. ---> 
System.AggregateException  ---> 
Elasticsearch.Net.PipelineException: An error occurred trying to read the response from the specified node

What are we doing wrong? Can we throw exceptions and make retries together?

NEST does not retry all exceptions; take a look at the failover and retries documentation. Essentially, for HTTP response codes in the range 500-599, the client will retry

  • 502 Bad Gateway
  • 503 Service Unavailable
  • 504 Gateway Timeout

The response will have an audit trail of what the client did, which can be read along with additional information about the request and response (if available) using .DebugInformation on response.

I suspect the response returned from Elasticsearch for NotEnoughMasterException is not to retry, and the exception is thrown.

1 Like

Thank you, it seems that it really is not to retry

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