We know that ElastiCache is not recommended to be accessed outside Amazon instances, so we're trying below stuff inside Amazon EC2 instances only.
We've got a ElastiCache Redis Cluster with 9 nodes. When we try to connect to it using normal redis implementation, it throws some Moved errors
Have tried the retry strategy method as per @Miller. Have also tried RedisCluster with unstable and stable (poor man) implementations.
None of these implementations are working. Any suggestions please?
Sign in to the AWS Management Console and open the ElastiCache console at https://console.aws.amazon.com/elasticache/ . To see a list of your clusters running the Memcached engine, in the left navigation pane, choose Memcached.
Open the Command Prompt and change to the Redis directory and run the command c:\Redis>redis-cli -h Redis_Cluster_Endpoint -p 6379 . Run Redis commands. You are now connected to the cluster and can run Redis commands like the following.
Create a Lambda function to access the ElastiCache cluster. When you create the Lambda function, you provide subnet IDs in your Amazon VPC and a VPC security group to allow the Lambda function to access resources in your VPC.
Sharing the code for future readers:
var RedisClustr = require('redis-clustr'); var RedisClient = require('redis'); var config = require("./config.json"); var redis = new RedisClustr({ servers: [ { host: config.redisClusterHost, port: config.redisClusterPort } ], createClient: function (port, host) { // this is the default behaviour return RedisClient.createClient(port, host); } }); //connect to redis redis.on("connect", function () { console.log("connected"); }); //check the functioning redis.set("framework", "AngularJS", function (err, reply) { console.log("redis.set " , reply); }); redis.get("framework", function (err, reply) { console.log("redis.get ", reply); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With