Not functioning properly with AWS ElastiCache
caffeines opened this issue · 1 comments
caffeines commented
We have used rsmq
successfully in our dev
environment having both redislab
connection and local docker instance of Redis. But in our production environment having AWS ElastiCache Redis instance inside a VPC, the code gets stuck forever inside RedisSMQ.createQueueAsync()
, although Redis connection succeeds instantly if this line is commented out.
The sample code-flow of my scenario is like the following:
let rsmq = new RedisSMQ({
host: config.redis.host,
port: config.redis.port,
password: config.redis.password,
ns: 'rsmq',
realtime: true,
});
const createQueue = async (queueName) => {
try {
const queue = await rsmq.createQueueAsync({
qname: queueName,
maxsize: -1,
vt: 10,
});
return queue;
} catch (err) {
if (err.message !== 'Queue exists') {
return Promise.reject(err);
}
return null;
}
};
Is there any special requirement for AWS ElastiCache connection?
t4sk commented
the code gets stuck forever inside RedisSMQ.createQueueAsync()
try calling process.exit(0)
at the end of your async node script. This worked for me
async function main() {
try {
const conn = new RedisSMQ({
host: config.redis.host,
port: config.redis.port,
password: config.redis.password,
ns: 'rsmq',
realtime: true,
});
console.log(`Creating queue...`)
await conn.createQueueAsync({ qname: "Q NAME"})
} catch (error) {
console.error(error)
process.exit(1)
}
process.exit(0)
}
main()