ErrorReply: NOAUTH Authentication required when using createCluster with redis in nodejs
I am trying to use elasticache redis cluster and using a password with it. When I try to write or read I am seeing. I am running out of ideas of things to try. I have tried to use password in the root node on the object and putting directly. I've tried other libraries and am seeing the same issues.
[ErrorReply: NOAUTH Authentication required.]
So here is the example of my code sorry for the mess.
const redis = require('redis');
const {
createCluster,
} = redis;
const password = 'abc123';
function getRedisClient() {
const rootNodes = [{
url: `rediss://:${password}@${host}:6379`,
rejectUnauthorized: true,
}];
return createCluster({
rootNodes,
defaults: {
socket: {
connectTimeout: 5000,
},
},
});
}
const cluster = getRedisClient();
cluster.on('error', (err) => console.log('Redis Cluster Error', err));
const run = async () => {
try {
await cluster.connect();
// console.log('cluster => ', cluster);
console.log('writing... => ');
const writeResult = await cluster.hSet('mkey', 'bob', 'my value');
console.log('reading... =>');
const readResult = await cluster.hGetAll('mykey');
//
// // console.log('writeResult => ', writeResult);
// console.log('readResult => ', readResult);
} catch (e) {
console.error(e);
}
}
run()
.catch((e) => console.error('error => ', e));
I have tried using ioredis, redis-clustr, and many different variations of variables. Using redis-cli it works just fine.
Comments
Post a Comment