-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Can't connect to ElastiCache redis cluster via NAT instance #693
Comments
Hi, haven't dug into this issue, but I remember there's an issue on the Redis repo about this issue: redis/redis#2527. The option |
Interesting, however there are a couple of problems:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs, but feel free to re-open a closed issue if needed. |
For now we've made a fork of ioredis in our private npm, and have modified code to support what we need. |
@jeremytm Sorry for the late response. I've already migrated the code to TypeScript and will submit a pull request for the NAT support (by adding a nat map option) in the next week. I'll let you know then. |
@jeremytm Would you like to share the modification of the code that works for your case or just make a pull request? |
It's pretty simple, and potentially not the safest option, but it works for us. It just passes the nodes in a callback provided via connection options. This callback is free to modify the nodes used by ioredis however it pleases. The callback we use is provided here:
Nat mappings would be something like:
|
@jeremytm Neat solution! A question for it though that since Redis Cluster returns IPs instead of hostnames, do you have to specify both IPs & hostnames? E.g. let's say rugby-cache-0001-001.xxxxxx.0001.use1.cache.amazonaws.com points to 172.189.1.2, the nat mappings should be:
|
Yeah, my bad, That's actually how ours looks. I just messed something up during copying and pasting while obfuscating the addresses. |
🎉 This issue has been resolved in version 4.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [4.3.0](redis/ioredis@v4.2.3...v4.3.0) (2018-12-09) ### Features * **cluster:** add NAT support ([#758](redis/ioredis#758)) ([3702d67](redis/ioredis@3702d67)), closes [#693](redis/ioredis#693) [#365](redis/ioredis#365)
We're using a single node cluster to test our workflow, and cannot connect via a NAT instance.
Having done some debugging, we get an error immediately after the node is connected:
Looking at the code this happens because the actual cluster node has an IP address from inside our VPC, while the NAT instance which we use to establish connectivity has a different public hostname. Because ioredis relies on the ip address of each node to create keys (or slots in the context of this error message), it thinks the node is missing and immediately disconnects it.
Is this something you guys would ever fix? I'm thinking some sort of map specified in connection options which maps the NAT hostname and port to the real VPC IP and ports could be a solution?
For anyone asking why we want to run local code with a remote redis implementation:
Usually our code runs remotely in AWS lambda. However our fastest dev workflow is where we test locally for convenience. Usually a local redis server is enough, but we regularly need to connect to a remote redis instance to debug with live data – and uploading our full repo to lambda on every iteration is way too slow.
Up until now we've used public redis instances in redislabs. However, we're moving to a more scalable solution in ElastiCache with redis cluster (which means running inside a VPC) and would like to be able to achieve the same fast workflow.
The text was updated successfully, but these errors were encountered: