首页 新闻 赞助 找找看

asp.net core中连接redis的问题

0
悬赏园豆:20 [已解决问题] 解决于 2018-01-18 11:31

Startup.cs中的代码如下:

var redisSection = Configuration.GetSection("redis");
var conf = redisSection.GetValue<string>("Configuration");
var redis = ConnectionMultiplexer.Connect(conf);
services.AddDataProtection().PersistKeysToRedis(redis, "DataProtection-Keys");

运行时却出现下面的错误:

System.Security.Cryptography.CryptographicException: An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information. ---> 
System.TimeoutException: Timeout performing LRANGE DataProtection-Keys, inst: 1, queue: 15, qu: 0, qs: 15, qc: 0, wr: 0, wq: 0, in: 17361, ar: 0, clientName:  (Please take a look at this article for some common client-side issues that can cause timeouts: https://github.com/StackExchange/StackExchange.Redis/tree/master/Docs/Timeouts.md)
   at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server)
   at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server)
   at StackExchange.Redis.RedisDatabase.ListRange(RedisKey key, Int64 start, Int64 stop, CommandFlags flags)
   at Microsoft.AspNetCore.DataProtection.RedisXmlRepository.<GetAllElementsCore>d__4.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Microsoft.AspNetCore.DataProtection.RedisXmlRepository.GetAllElements()
问题补充:

这个问题似乎与StackExchange.Redis对Linux的支持有关

dudu的主页 dudu | 高人七级 | 园豆:31075
提问于:2017-01-03 19:07
< >
分享
最佳答案
0

是 StackExchange.Redis 对 .NET Core 支持的一个bug,详见:asp.net core concurrency issues

dudu | 高人七级 |园豆:31075 | 2017-01-04 11:42

后来没办法了,下载 csredis 改成 .netcore 版使用在项目中

https://github.com/2881099/csredis

nicye | 园豆:208 (菜鸟二级) | 2017-01-06 16:39

并且我们项目中发现这个问题的时候,大概是10月份,statckexchage.redis 非常坑

代码很乱很难看,相比csredis就干净很多

nicye | 园豆:208 (菜鸟二级) | 2017-01-06 16:41
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册