RedisConnectionException

Category: azure cache

Question

ssashok10 on Wed, 06 Mar 2019 00:02:28


I am using the standard tier Redis Cache for my testing and I ran the sample code from MSDN site. I keep getting the connection issue below,

"System.AggregateException
  HResult=0x80131500
  Message=One or more errors occurred. (No connection is available to service this operation: PING; UnableToConnect on aap-local-cache.redis.cache.windows.net:6380/Interactive, Initializing, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 5s ago, last-write: 5s ago, unanswered-write: 21031s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.0.519.65453; IOCP: (Busy=0,Free=1000,Min=4,Max=1000), WORKER: (Busy=0,Free=32767,Min=4,Max=32767), Local-CPU: n/a)
  Source=System.Private.CoreLib
  StackTrace:
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at RedisCacheTest.Program.Main(String[] args) in C:\AAP\Apps\Samples\RedisCacheTest\RedisCacheTest\Program.cs:line 39"

Here is the MSDN code,

using System;
using StackExchange.Redis;
using Microsoft.Azure.KeyVault;
using Microsoft.Azure.Services.AppAuthentication;

namespace RedisCacheTest
{
    class Program
    {
        private static Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() =>
        {
            string cacheConnection = "xxxxxx"; // port 6380
            return ConnectionMultiplexer.Connect(cacheConnection);
        });

        public static ConnectionMultiplexer Connection
        {
            get
            {
                return lazyConnection.Value;
            }
        }
        static void Main(string[] args)
        {

            IDatabase cache = lazyConnection.Value.GetDatabase();

            // Perform cache operations using the cache object...

            // Simple PING command
            string cacheCommand = "PING";
            Console.WriteLine("\nCache command  : " + cacheCommand);
            Console.WriteLine("Cache response : " + cache.ExecuteAsync(cacheCommand).Result);

            // Simple get and put of integral data types into the cache
            cacheCommand = "GET Message";
            Console.WriteLine("\nCache command  : " + cacheCommand + " or StringGet()");
            Console.WriteLine("Cache response : " + cache.StringGet("Message").ToString());

            cacheCommand = "SET Message \"Hello! The cache is working from a .NET console app!\"";
            Console.WriteLine("\nCache command  : " + cacheCommand + " or StringSet()");
            Console.WriteLine("Cache response : " + cache.StringSet("Message", "Hello! The cache is working from a .NET console app!").ToString());

            // Demonstrate "SET Message" executed as expected...
            cacheCommand = "GET Message";
            Console.WriteLine("\nCache command  : " + cacheCommand + " or StringGet()");
            Console.WriteLine("Cache response : " + cache.StringGet("Message").ToString());

            // Get the client list, useful to see if connection list is growing...
            cacheCommand = "CLIENT LIST";
            Console.WriteLine("\nCache command  : " + cacheCommand);
            Console.WriteLine("Cache response : \n" + cache.Execute("CLIENT", "LIST").ToString().Replace("id=", "id="));

            lazyConnection.Value.Dispose();

        }
    }
}

Replies

Kalyan Chanumolu-MSFT on Wed, 06 Mar 2019 05:18:18


Hello ssashok,

I tried your code and it works perfectly for me.

I tested this inside a console app running .Net Core 2.2 and StackExchange.Redis.Extensions.NetCore version 1.0.1

What version are you running? 

Cache command  : PING
Cache response : PONG

Cache command  : GET Message or StringGet()
Cache response :

Cache command  : SET Message "Hello! The cache is working from a .NET console app!" or StringSet()
Cache response : True

Cache command  : GET Message or StringGet()
Cache response : Hello! The cache is working from a .NET console app!

Cache command  : CLIENT LIST
Cache response :
id=10323 addr=###.220.238.159:21763 fd=19 name=#####-LPTP age=2 idle=2 flags=N db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 ow=0 owmem=0 events=r cmd=subscribe numops=5
id=10324 addr=###.220.238.159:1481 fd=21 name=#####-LPTP age=2 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 ow=0 owmem=0 events=r cmd=client numops=17
id=10185 addr=10.0.0.5:30290 fd=14 name=PORTAL_CONSOLE age=65 idle=65 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 ow=0 owmem=0 events=r cmd=ping numops=4

Do you see the Console Option on Redis instance? 

Could you please try running the commands there and let me know if they work

ssashok10 on Wed, 06 Mar 2019 14:57:09


Thanks for your quick response. I am using .NET Core 2.1 and StackExchange.Redis 2.0.519. I have uninstalled this Redis package and tried with "StackExchange.Redis.Extensions.NetCore version 1.0.1" as well. I am getting the same issue again. The proxy server on my environment is configured to whitelist "*.windows.net" as well.

ssashok10 on Wed, 06 Mar 2019 15:39:07


I tried the command mode and I am not getting any response too.

Kalyan Chanumolu-MSFT on Wed, 06 Mar 2019 17:05:44


Could you please check if you are on a Premium tier and if your Redis Cache part of a VNET?

If Yes, The Redis Console from the Portal will not work.

Only clients inside the VNET can access the cache. Please deploy your app to a service in the VNET and let me know if you still face any issues.


ssashok10 on Wed, 06 Mar 2019 17:13:16


This Redis cache is not part of our VNET. We are using the Azure PAAS offerings without VNET attached on it. Here is the error that I am seeing on the console,

Connection Failure: If this issue persists, ensure your computer's firewall and proxy settings allow outbound TCP traffic to port 10225. Using the firewall feature on your cache may also block connections from the console if your IP address has not been whitelisted.

Kalyan Chanumolu-MSFT on Wed, 06 Mar 2019 17:30:18


Please check the Firewall blade on your Redis Cache.

No rules are defined. Connections are allowed from any IP address (default configuration).

If you see the above message, you are most probably behind an enterprise/corporate firewall that is blocking outbound traffic to the Redis host.

Please work with your Network admin to whitelist the same.

Kalyan Chanumolu-MSFT on Thu, 07 Mar 2019 16:55:00


Just checking in to see if the above answer helped.

If this answers your query, do click “Mark as Answer” and Up-Vote for the same which might be beneficial to other community members reading this thread.