You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting the following error , when we are truing to get connection Error: Redis is already connecting/connected
here is redisio package node env
ioredis: "5.2.3"
node : v18.12.0
Here is our client
//sample.js
const rc = (callback) => {
let rc = null,
r_url = 'xxxx';
if (global.rc) {
rc = global.rc;
return callback(null, rc);
} else {
(
async (callback) => {
if (!r_url) {
console.log('redisURL not found');
return callback();
}
// Create a Redis instance.
try {
const [host, port] = redisURL.split(':');
rc = new Redis.Cluster([
{
host,
port
}
], {
scaleReads: 'all',
dnsLookup: (address, callback) => callback(null, address),
commandTimeout: 3000, // all timestamps used here are in milliseconds
connectTimeout: 5000,
disconnectTimeout: 2000,
maxRetriesPerRequest: 2,
enableOfflineQueue: true,
showFriendlyErrorStack: true,
autoResendUnfulfilledCommands: true, // If true, client will resend unfulfilled commands(e.g. block commands) in the previous connection when reconnected. defaults to true
lazyConnect: false,
clusterRetryStrategy(times) {
if (times % 2 === 0) {
console.error('redisRetryError : Redis reconnect exhausted after 3 retries.');
return null;
}
return 200;
},
reconnectOnError(err) {
const targetError = 'READONLY';
if (err.message.includes(targetError)) {
// Only reconnect when the error contains "READONLY"
return true; // or `return 1;`
}
},
});
await rc.connect();
if (rc && rc.status === 'ready') {
global.rc = rc;
console.log('[redisClient] : redis connection ready');
} else {
global.rc = null;
}
callback(null, rc);
} catch(err) {
console.log(err)
callback(err);
}
}
)()
}
};
Now ehn I make Call to redisClient
//CALLER
//GETTING the CLIENT
rc((e, r_conn)=> {
if (r_conn && r_conn.status === 'ready') {
//..... Do something like get or set
} else {
console.error(e);
}
})
here we the above we are seeing the above mentioned error?
Any suggestion what we are doing wrong here
The text was updated successfully, but these errors were encountered:
abuzarhamza
changed the title
aws elesttic redis clustor connection error with global variable
aws elesttc redis cluster connection error with global variable
Jan 30, 2024
Hi All
I am getting the following error , when we are truing to get connection
Error: Redis is already connecting/connected
here is redisio package node env
Here is our client
Now ehn I make Call to redisClient
here we the above we are seeing the above mentioned error?
Any suggestion what we are doing wrong here
The text was updated successfully, but these errors were encountered: