Handling of transient network errors with StackExchange.Redis

Viewed 2991

Looking for guidance on handling temporary network issues when using the StackExchange.Redis client.

For clarification, I do not mean initially connecting to the Redis server with ConnectionMultiplexer.Connect(). I am referring to how to handle connections that are interrupted for whatever reason in the middle of an operation. (we can assume that the command is idempotent, StringSet, StringGet)

I ask because we are migrating from the ServiceStack to the StackExchange client. In the code we are replacing, which uses ServiceStack, exceptions were caught and the operation would be attempted again after a short thread.sleep(). This happens fairly frequently in our production environment and on most occasions the retry would work.

Usually it's a System.Net.SocketException with the message "An established connection was aborted by the software in your host machine" or "An existing connection was forcibly closed by the remote host"

If a System.Net.SocketException is thrown, does StackExchange.Redis automatically retry up until the syncTimeout time has elapsed?

If SE.Redis does not automatically retry, are there any suggested steps that should happen between an initial operation failure and a retry in our code? Such as:

  • waiting a short amount of time?
  • recreating the multiplexer? (I'd guess not)
  • calling Close() and Configure()?

Thank you for any guidance.

1 Answers
Related