[英]StackExchange.Redis: No connection is available to service this operation: SET
I created a Console Application running on .NET Core 1.1 and I'm referencing the StackExchange.Redis NuGet package, version 1.2.3我创建了一个在 .NET Core 1.1 上运行的控制台应用程序,我正在引用 StackExchange.Redis NuGet package,版本 1.2.3
When running the code below, I get the following error:运行下面的代码时,出现以下错误:
It was not possible to connect to the redis server(s);无法连接到 redis 服务器; to create a disconnected multiplexer, disable AbortOnConnectFail.要创建断开连接的多路复用器,请禁用 AbortOnConnectFail。 SocketFailure on PING PING 上的 SocketFailure
using StackExchange.Redis;
using System;
namespace RedisConsoleApp
{
class Program
{
static void Main(string[] args)
{
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
IDatabase db = redis.GetDatabase();
db.StringSet(BitConverter.GetBytes(5), "asdf");
}
}
}
If I change the Connect string to "localhost,abortConnect=false"
, then I get this error message:如果我将连接字符串更改为"localhost,abortConnect=false"
,则会收到此错误消息:
No connection is available to service this operation: SET \0\0\0;没有可用于服务此操作的连接:SET \0\0\0; SocketFailure on localhost:6379/Subscription, origin: Error, input-buffer: 0, outstanding: 0, last-read: 1s ago, last-write: 1s ago, unanswered-write: 27780s ago, keep-alive: 60s, pending: 0, state: Connecting, last-heartbeat: never, last-mbeat: -1s ago, global: 20s ago本地主机上的 SocketFailure:6379/订阅,来源:错误,输入缓冲区:0,未完成:0,最后读取:1 秒前,最后写入:1 秒前,未答复写入:27780 秒前,保持活动:60 秒,待定: 0, state: Connecting, last-heartbeat: never, last-mbeat: -1s ago, global: 20s ago
I followed the Basics guide to get started using this library but I keep getting the errors above.我按照基础指南开始使用这个库,但我不断收到上述错误。
Am I missing some code or configuration?我是否缺少某些代码或配置?
It sounds like you might have only set up the StackExchange.Redis client, did you install and start up your local Redis server? 听起来您可能只设置了StackExchange.Redis客户端,您是否安装并启动了本地Redis服务器? If not, use HomeBrew to download and install Redis on your machine 如果没有,请使用HomeBrew在您的计算机上下载并安装Redis
brew install redis
brew services start redis
and start the server with 然后启动服务器
redis-server
Try adding ssl=True,abortConnect=False,sslprotocols=tls12
under your connection string尝试在连接字符串下添加ssl=True,abortConnect=False,sslprotocols=tls12
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.