我已经安装PM> Install-Package ServiceStack.Redis
并使用以下代码连接azure redis缓存。
我想我错过了连接字符串,因为我没有在主机
中给出PRIMARY KEY
string host = "mydemo.redis.cache.windows.net";
var redisManager = new PooledRedisClientManager(host);
using (var redisClient = redisManager.GetClient())
{
IRedisTypedClient<Customer> redis = redisClient.As<Customer>();
出现错误:
{"could not connect to redis Instance at mydemo.redis.cache.windows.net:6379"}
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 11.22.216.225:6379
最佳答案
这是一个基本的网络连接错误。您需要确保您有权连接到 mydemo.redis.cache.windows.net
上的 TCP 端口 6379 (11.22.216.225:6379),并根据需要打开任何防火墙规则。
您可以使用 telnet 或在您尝试使用 redis-windows 的同一服务器上运行 redis-cli.exe
(来自 ServiceStack.Redis )来测试 TCP 连接。 ,例如:
redis-cli -h 11.22.216.225 -p 6379
SSL Redis Connections to Azure Redis
连接字符串(如果您是 trying to connect to a redis-server on Azure)通常采用以下格式:
{AzureRedisKey}@servicestackdemo.redis.cache.windows.net?ssl=true
?ssl=true
选项表示在默认端口 Azure SSL 端口 6380 上使用 SSL。
关于azure - 无法使用 ServiceStack.Redis 库连接 Redis 缓存服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31984733/