RedisConnectionException [英] RedisConnectionException

查看:77
本文介绍了RedisConnectionException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用标准层Redis缓存进行测试,我从MSDN站点运行了示例代码。我一直收到下面的连接问题,

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

 消息=发生了一个或多个错误。 (没有可用于此操作的连接:PING; 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:connected,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:不适用)

  Source = System.Private.CoreLib

  StackTrace:

   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)

  在RedisCacheTest.Program.Main(String [] args)中的C:\ AAP\Apps \ Samples \ RededCacheTest \ RededCacheTest \ Programrcs:第39行"

"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"

这是MSDN代码,

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();

        }
    }
}

推荐答案

你好ssashok,

Hello ssashok,

我试过你的代码吧对我来说非常适合。

I tried your code and it works perfectly for me.

我在运行.Net Core 2.2和StackExchange.Redis.Extensions.NetCore版本1.0.1的控制台应用程序中测试了这个。

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

您是否在Redis实例上看到Console Option? 

Do you see the Console Option on Redis instance? 

你可以尝试在那里运行命令,让我知道它们是否有效

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


这篇关于RedisConnectionException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆