无法从.net应用程序连接aws elasticache redis

wz1wpwve  于 2021-06-09  发布在  Redis
关注(0)|答案(1)|浏览(616)

我正在将.net核心应用程序连接到aws elasticache redis。

aws elasticache redis正在运行,security group上的端口6329已打开。客户端代码正在使用 StackExchange.Redis :

var redis = ConnectionMultiplexer.Connect("redis-1.xxxx.0001.use1.cache.amazonaws.com:6379");
           //var redis = ConnectionMultiplexer.Connect("localhost"); //working
           IDatabase db = redis.GetDatabase();

            string value = "abcdefg";
            db.StringSet("mykey", value);        

            string value2 = db.StringGet("mykey");
            Console.WriteLine(value2); // writes: "abcdefg"

            Console.ReadLine();

例外情况是:
无法连接到redis服务器。无法连接redis-1..0001.use1.cache.amazonaws。com:6379/interactive,初始化/未启动,上次:无,源:beginconnectasync,未完成:0,上次读取:5s前,上次写入:5s前,保持活动状态:60s,状态:正在连接,管理器:10/10可用,上次心跳:从不,全局:0s前,v:2.0.601.3402
添加到 ,abortConnect=false 到终点,我可以连接。
现在错误在 StringSet stackexchange.redis.redisconnectionexception:'没有可用于服务此操作的连接:set mykey;无法连接。。。
net代码与我的本地redis服务配合得很好,所以我的aws设置看起来不正确。
成功 ssh 到我的ec2示例和redis cli到我的aws redis服务:

有什么想法吗?
注意:默认情况下,aws elasticache redis不可用于公共访问。
https://docs.aws.amazon.com/amazonelasticache/latest/red-ug/accessing-elasticache.html#access-来自aws外部
你能连接亚马逊elasti吗с亚马逊之外有什么?

7z5jn7bk

7z5jn7bk1#

问题:“…端口6329在安全组上打开…”您不是说6379吗?
即便如此,我想我对“默认”子网组也有意见。
aws elasticache redis所在的vpc\ U子网(在该组中)是否有访问internet网关的路由表?如果没有,则需要将internetgteway附加到路由表,然后在所需的子网上使用该路由表。
它应该像一个选择:互联网

相关问题