azure - 无法使用 ServiceStack.Redis 库连接 Redis 缓存服务器

标签 azure caching redis servicestack.redis

我已经安装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/

相关文章:

powershell - 用于交换 Azure 应用服务(网站)部署槽的 Azure Powershell 脚本

azure - 如何实现从Azure Event Hub的高速处理接收?

nhibernate - Windows Azure 中的多个 NHibernate 实例是否需要外部二级缓存?

azure - 在 Windows Azure VM (Windows) 上设置 Redis,并使其可访问同一云服务下的其他 VM

c# - StackExchange.Redis ListRightPop 不等待结果

sql-server - 为什么在本地运行的应用程序与azure中会出现时间(UTC)差异?

.net - 未为项目 '.sfproj' 设置 BaseOutputPath/OutputPath 属性

c# - 如何使用 gzip 压缩 .net 对象实例

caching - 回写式缓存与直写式缓存?

perl - 如何手动安装 Redis perl 库,即离线。以及从哪里可以获取所有要安装的依赖项