我正在尝试从 C# 连接 REDIS 数据库(GCP-memorystore-Redis)。在为 Redis 设置值时,我遇到了如下异常:
没有可用于服务此操作的连接。UnableToConnect on 10.0.0.2 : 6379 / Interactive , Initializing, last: NONE, origin: BeginConnectAsync, 未完成: 0, last-read: 10s ago, last-write: 10s ago, unanswered-write: 115s ago, keep-alive: 180s ,状态:正在连接,管理器:10 个可用,10 个可用,最后一次心跳:从不,全局:0 秒前,v:2.0.519.65453;IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=1,Free=32766,Min=1,Max=32767), Local-CPU: n/a
我正在使用StackExchange.Redis版本:2.0.519
代码:
IDatabase redisDB;
try {
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect($"{host}:{port},resolvedns=1,abortConnect=False,keepAlive=180,connectTimeout=10000");
redisDB = redis.GetDatabase();
if(redisDB==null)
{
**//Getting Error**
var messageId = redisDB.StreamAdd("event_stream", "foo_name", "bar_value");
//redisDB.StringSet("RedisKey", "RedisValue");
}
}
(或)我也试图通过使用下面的代码来设置值。(遇到同样的问题)
redisDB.StringSet("RedisKey", "RedisValue");
你能帮忙吗?