【问题标题】:It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING无法连接到 redis 服务器;要创建断开连接的多路复用器,请禁用 AbortOnConnectFail。 PING 上的 SocketFailure
【发布时间】:2015-05-16 09:45:45
【问题描述】:

我正在尝试做一个从 azure redis 缓存读取和写入的简单示例,但出现此错误

StackExchange.Redis.dll 中发生了“StackExchange.Redis.RedisConnectionException”类型的异常,但未在用户代码中处理

附加信息:无法连接到 redis 服务器;要创建断开连接的多路复用器,请禁用 AbortOnConnectFail。 PING 上的 Socket 失败

我用的代码是这个,我改了dns和密码

// Get Connection instance
ConnectionMultiplexer connection = ConnectionMultiplexer
    .Connect("xx.redis.cache.windows.net,ssl=false,password=...");
// Get database
IDatabase databaseCache = connection.GetDatabase();
// Add items
databaseCache.StringSet("foo1", "1");
databaseCache.StringSet("foo2", "2");
// Add items with experation value
databaseCache.StringSet("foo3", "3", TimeSpan.FromMinutes(20));

Stopwatch sw = new Stopwatch();

sw.Start();

// Get item value
string foo1Value = databaseCache.StringGet("foo1");

sw.Stop();

Console.WriteLine("Elapsed={0}", sw.Elapsed);
return View();

【问题讨论】:

标签: c# asp.net azure redis stackexchange.redis


【解决方案1】:

默认情况下,Azure Redis 缓存仅启用 SSL 终结点。最安全的方法是在调用 ConnectionMultiplexer.Connect() 时设置“ssl=true”。

或者,您可以使用 Azure 门户在您的 Azure Redis 缓存上启用非 SSL 端点,但是您的密码和所有数据都将以明文形式发送。

【讨论】:

【解决方案2】:

我遇到了完全相同的异常,结果是公司防火墙阻止了端口 6379、6380。

我在公司网络外部的环境中复制了我的测试控制台应用程序,并且连接成功。 因此,如果 Redis 服务器在 Internet 上运行并且您的网络位于防火墙后面,请确保端口已打开。

【讨论】:

  • 作为备注:6380 端口用于 SSL。用于非 SSL 连接的 6379 端口。
猜你喜欢
  • 1970-01-01
  • 2017-07-22
  • 2013-02-25
  • 2017-03-01
  • 2019-10-18
  • 1970-01-01
  • 2023-01-11
  • 2023-02-11
  • 1970-01-01
相关资源
最近更新 更多