Reputation: 10247
I'm trying to connect an ElastiCache Redis to an Express server deployed on ECS. I'm using the Official Redis package for Node.js
I get the Primary Endpoint from ElastiCache as blablabla.mccjet.ng.0001.euc1.cache.amazonaws.com:6379
In my server I try to connect like this
const { createClient } = require("redis");
const pubClient = createClient({ url: 'blablabla.mccjet.ng.0001.euc1.cache.amazonaws.com:6379' });
But when I check the ECS logs I see
/usr/src/app/node_modules/@redis/client/dist/lib/client/index.js:124
throw new TypeError('Invalid protocol');
^
TypeError: Invalid protocol
at Function.parseURL (/usr/src/app/node_modules/@redis/client/dist/lib/c...
Haven't used Redis so no idea why this is happening. Any idea how to use the endpoint properly
even tried with
const pubClient = createClient({ host: 'blablabla.mccjet.ng.0001.euc1.cache.amazonaws.com', port:6379 });
but that also didn't work
Upvotes: 2
Views: 97763
Reputation: 10247
The issue was I had to add the prefix redis://
before my Primary endpoint so that it becomes redis://blablabla.mccjet.ng.0001.euc1.cache.amazonaws.com:6379
Github Issue
const pubClient = createClient({ url: 'redis://blablabla.mccjet.ng.0001.euc1.cache.amazonaws.com:6379' });
Upvotes: 7