Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster retry strategy and reconnection #1437

Open
lueenavarro opened this issue Sep 29, 2021 · 0 comments
Open

Cluster retry strategy and reconnection #1437

lueenavarro opened this issue Sep 29, 2021 · 0 comments

Comments

@lueenavarro
Copy link

lueenavarro commented Sep 29, 2021

In a single instance redis, there is an option maxRetriesPerRequest which works.

However, if I am using a cluster, the only thing that works is clusterRetryStrategy:

    clusterRetryStrategy: (times) => {
      const retryLimit = 2;
      if (times < retryLimit) return Math.min(100 + times * 2, 2000);
      return false;
    },

It works but when I make another request, it says that the connection is closed. I read somewhere that is the intended behavior and you need to call cluster.connect() to restore the connection.

My question is how can I make sure that the connection is restored when another request is made? I could check if the cluster is connected on every request and if not, I will connect to it but that seems to be tedious. Is there a more elegant solution?

In summary, I want a to use the behavior of maxRetriesPerRequest in a clustered Redis.

@lueenavarro lueenavarro changed the title Cluster retry strategy Cluster retry strategy and reconnection Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant