Open neonexus opened 7 years ago
@neonexus please make an issue on the ioredis repo, will take a look there.
@Salakar there's no need, I found the fix yesterday as I was leaving work. Ultimately, it would be good to make mention of this in the documentation.
Because AWS Elasticache Redis Clusters are designed to be used with a single endpoint address, I was configuring the connection with "host". Didn't realize I had to use "hosts: [{host: 'Elasticache CFG Endpoint'}]" to trigger the clustering options. Once I fixed the config, everything worked again.
I was having trouble with this too so I'm posting my solution to connect to an AWS Redis (ElasticCache) cluster.
I had the most success using the ioredis package for connecting to Redis from a Node.js script on my EC2 instance.
I used the path that AWS calls the "Configuration Endpoint" for redisHost
and redisPort
.
My EC2 is behind a VPC, so I also made sure my inbound network connections allowed port 6379 as documented here.
This solution also fixed the MOVED
error I would see when trying to set a value in Redis.
const Redis = require('ioredis');
var client = new Redis.Cluster([`//${redisHost}:${redisPort}`], {
scaleReads: 'slave'
});
client.hget(key, id).then(data => {
// manipulate data
});
client.hgetall(key).then(data=>{
// manipulate data
});
thank you for the insight! will help me a lot :)
When using AWS's Elasticache Redis Cluster (has built-in failover / replication / load balancing, no need to know the server addresses), occasionally Elasticache has to move data around, so it issues a MOVED Redirect, but this causes the adapter to fail, so Sails falls flat on it's face during lift. This is the console output I get when attempting to lift the app:
As you can probably tell, I have a model called ActivePeople that uses the adapter; it tracks live usage of the app (and wether or not the app is in focus).
Please help!