I've setup a Redis caching and for that I've a Redis-server running on wsl2 and client on NodeJS platform. As soon as the redis-server went down I've to make a few connections that too with a waiting time, but it's making reconnection requests continuously even if I'm using this package(node-redis-retry-strategy).
Here's my code
const redis = require('redis');
var retryStrategy = require("node-redis-retry-strategy");
var client = redis.createClient({
host: "localhost",
port: 6379,
retry_strategy: retryStrategy()
});
client.connect()
client.on("connect", function(){
console.log("connected to redis server !!!")
client.on("reconnecting",function(){
console.log("inside reconnecting")
})
client.on("error",function(error ){
console.log(error)
})
And also I've tried sending option argument
const redis = require('redis');
var retryStrategy = require("node-redis-retry-strategy");
var client = redis.createClient({
host: "localhost",
port: 6379,
retry_strategy: retryStrategy({
allow_to_start_without_connection: true,
number_of_retry_attempts: 7,
delay_of_retry_attempts: 1000
})
});
client.connect()
client.on("connect", function(){
console.log("connected to redis server !!!")
client.on("reconnecting",function(){
console.log("inside reconnecting")
})
client.on("error",function(error ){
console.log(error)
})
And the versions for redis and the retrystrategy package I'm using is
"redis": "^4.3.1",
"node-redis-retry-strategy": "^2.1.1",
additional data
node version v16.17.1
for setting redis-server locally I've used : v=7.0.5 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=68bf11aad5b039df
And I'm using WSL2
I'm using 4.4.0 and was looking for auto reconnect solution. And it looks like there is no such option, so it appears to be not supported.
So what I've done is just setting up reconnection by hand