项目中使用到redis 做完缓存,
dll 用的是ServiceStack.Redis
版本:
<PackageReference Include="ServiceStack.Redis" Version="5.10.2" />
<PackageReference Include="StackExchange.Redis" Version="2.2.4" />
redis连接帮助类是RedisBase
private static string[] ReadWriteHosts = { ConfigRead.GetInstance.GetAppsetConnection().RedisIp };
private static string[] ReadOnlyHosts = { ConfigRead.GetInstance.GetAppsetConnection().RedisIp };
#region -- 连接信息 --
public static PooledRedisClientManager Prcm = CreateManager(ReadWriteHosts, ReadOnlyHosts);
private static PooledRedisClientManager CreateManager(string[] readWriteHosts, string[] readOnlyHosts)
{
// 支持读写分离,均衡负载
return new PooledRedisClientManager(readWriteHosts, readOnlyHosts, new RedisClientManagerConfig
{
MaxWritePoolSize = 10000, // “写”链接池链接数
MaxReadPoolSize = 10000, // “读”链接池链接数
DefaultDb = ConfigRead.GetInstance.GetAppsetConnection().RedisDb,
AutoStart = true,
});
}
异常信息:
MethodName:OnException [(null)]
ServiceStack.Redis.RedisException: Exceeded timeout of 00:00:10
---> System.Net.Sockets.SocketException (10060): 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at ServiceStack.Redis.RedisNativeClient.SendReceive[T](Byte[][] cmdWithBinaryArgs, Func1 fn, Action
1 completePipelineFn, Boolean sendWithoutRead) in C:\BuildAgent\work\b2a0bfe2b1c9a118\src\ServiceStack.Redis\RedisNativeClient_Utils.cs:line 722
at ServiceStack.Redis.RedisNativeClient.SendExpectData(Byte[][] cmdWithBinaryArgs) in C:\BuildAgent\work\b2a0bfe2b1c9a118\src\ServiceStack.Redis\RedisNativeClient_Utils.cs:line 782
at ServiceStack.Redis.RedisClient.<>c__DisplayClass452_01.<Get>b__0(RedisClient r) in C:\BuildAgent\work\b2a0bfe2b1c9a118\src\ServiceStack.Redis\RedisClient.ICacheClient.cs:line 49 at ServiceStack.Redis.RedisClient.Exec[T](Func
2 action) in C:\BuildAgent\work\b2a0bfe2b1c9a118\src\ServiceStack.Redis\RedisClient.ICacheClient.cs:line 31
at Hh.Mes.Common.Redis.RedisBase.GetT[T](String key) in D:\工程项目\开发中项目\中海油\TJZHY_MES\Hh.Mes.Common\Redis\RedisBase.cs:line 519
at Hh.Mes.API.AOP.AuthFilterAttribute.OnActionExecuting(ActionExecutingContext context) in D:\工程项目\开发中项目\中海油\TJZHY_MES\Hh.Mes.API\AOP\AuthFilterAttribute.cs:line 92
at Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
日志里面打印这个错误还是挺频繁的, 访问量也不大 不多,
请问朋友们 你们是怎么解决呢?
建议检查一下 redis 服务器
换成freeRedis 组件 解决了,这个错误网上也看到很多人提出
把线程最小并发设大点,比如:ThreadPool.SetMinThreads(1000, 1000);
查看一下redis 版本~最新的servicestack 是需要高版本的redis来支持的,底层的API不一样。
换成freeRedis 组件 解决了,这个错误网上也看到很多人提出