简体   繁体   中英

Unable to connect AWS Redis cache in .net C# - RedisConnectionException: 'No connection is active/available to service this operation

I have created AWS ElasticCache - redisCache in console. I want to access same from .net core/framework application - But unable to connect same.

        ConfigurationOptions option = new ConfigurationOptions
        {
           AbortOnConnectFail = false,
           Ssl = true,
           ConnectTimeout =5000,
           KeepAlive = 2,
           EndPoints = { "xxxxxxxxxx.cache.amazonaws.com:6379" }
        };

        ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(option);
        IDatabase db = redis.GetDatabase();
        string value = "abcdefg";
        db.StringSet("mykey", value);
        string getValue = db.StringGet("mykey");
        return getValue;

Gettitng below error -

StackExchange.Redis.RedisConnectionException: 'No connection is active/available to service this operation: SET mykey; UnableToConnect on xxxxx.cache.amazonaws.com:6379/Interactive, Initializing/NotStarted, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 5s ago, last-write: 5s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 5s ago, v: 2.2.88.56325, mc: 1/1/0, mgr: 10 of 10 available, clientName: machineId, IOCP: (Busy=0,Free=1000,Min=8,Max=1000), WORKER: (Busy=1,Free=32766,Min=8,Max=32767), v: 2.2.88.56325'

In my case the issue was related with the DNS. (I am using a VPN to access Redis). So what I did was put the google DNS in my wifi connection and that did the trick:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM