Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Invalid protocol" when trying to connect to Elasticache Redis in Node.js #2201

Closed
cmgchess opened this issue Jul 18, 2022 · 6 comments
Closed

Comments

@cmgchess
Copy link

Hello

I'm trying to connect an ElastiCache Redis to an Express server deployed on ECS.

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...

Any help on what I might be missing
Thanks

@leibale
Copy link
Collaborator

leibale commented Jul 18, 2022

this should fix it

const pubClient = createClient({ url: 'redis://blablabla.mccjet.ng.0001.euc1.cache.amazonaws.com:6379' });

@cmgchess
Copy link
Author

Thanks!

Now I'm getting a Redis error ConnectionTimeoutError.... exactly similar to #1656. after looking at the stack trace
but anyway this should mean I connected to Redis at least once?

@leibale
Copy link
Collaborator

leibale commented Jul 18, 2022

Have you tried connecting using redis-cli?

@cmgchess
Copy link
Author

i tried with that too
C:\WINDOWS\system32>redis-cli -h blablabla.mccjet.ng.0001.euc1.cache.amazonaws.com -p 6379

and got
Could not connect to Redis at blablabla.mccjet.ng.0001.euc1.cache.amazonaws.com:6379: Unknown error not connected>

even whitelisted my IP in inbound rules of security group
and then found this
i'll try some other things as well

@cmgchess
Copy link
Author

However I managed to connect to it from an AWS EC2 using EC2 Instance Connect.

@cmgchess
Copy link
Author

cmgchess commented Aug 2, 2022

I guess this is how it behaves and I cannot access elasticache from a local machine without SSH. Anyway it works fine inside the cloud.
closing this
Thanks for helping me out!

@cmgchess cmgchess closed this as completed Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants