Reputation: 91
Am trying to connect to AWS redis elastic cache, but i keep getting this error all the time. I am not sure what i am doing wrong here, any help is greatly appreciated. Here's my code
async function testRedis(){
try{
const asyncRedis = require("async-redis");
const client = asyncRedis.createClient({
port: 6379,
host: 'myHost',
auth_pass: redisPassword,
connect_timeout: 900,
enable_offline_queue: false
})
const response = await client.set("test", "response");
const redisResp = await client.get("test");
const connStatus = client.quit()
console.log('connection status::', connStatus)
} catch (err) {
console.log(err)
}
}
Upvotes: 3
Views: 10158
Reputation: 243
I had the same issue. My host didn't an provide IP address for host option so I fixed it by using a connection string: [redis[s]:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]
Should look something like:
const connectionString = 'rediss://username:password@url-to-your.redis.db.server.com:2500'
const client = asyncRedis.createClient(connectionString);
Async redis is a wrapper over Node Redis: https://www.npmjs.com/package/redis Check out the docs for more info.
Upvotes: 1