Caused by: io.lettuce.core.RedisCommandTimeoutException: Command timed out after 10 second(s) at io.lettuce.core.ExceptionFactory.createTimeoutException(ExceptionFactory.java:51) at io.lettuce.core.LettuceFutures.awaitOrCancel(LettuceFutures.java:114) at io.lettuce.core.FutureSyncInvocationHandler.handleInvocation(FutureSyncInvocationHandler.java:69) at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80) at com.sun.proxy.$Proxy110.rpop(Unknown Source) at org.springframework.data.redis.connection.lettuce.LettuceListCommands.rPop(LettuceListCommands.java:353) ... 13 more org.springframework.dao.QueryTimeoutException: Redis command timed out; nested exception is io.lettuce.core.RedisCommandTimeoutException: Command timed out after 10 second(s) at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:70) at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41) at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44) at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42) at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:270) at org.springframework.data.redis.connection.lettuce.LettuceListCommands.convertLettuceAccessException(LettuceListCommands.java:490) at org.springframework.data.redis.connection.lettuce.LettuceListCommands.rPop(LettuceListCommands.java:355) at org.springframework.data.redis.connection.DefaultedRedisConnection.rPop(DefaultedRedisConnection.java:643) at org.springframework.data.redis.core.DefaultListOperations$4.inRedis(DefaultListOperations.java:197) at org.springframework.data.redis.core.AbstractOperations$ValueDeserializingRedisCallback.doInRedis(AbstractOperations.java:60) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:228) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:188) at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96) at org.springframework.data.redis.core.DefaultListOperations.rightPop(DefaultListOperations.java:193) at com.ncs.deep.forgery.reptile.untils.RedisUtil.lrightGetRemove(RedisUtil.java:510) at com.ncs.deep.forgery.reptile.jsoup.WebSiteJsoupThread.action(WebSiteJsoupThread.java:53) at com.ncs.deep.forgery.reptile.threadabstract.RunnableFactory.run(RunnableFactory.java:15) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: io.lettuce.core.RedisCommandTimeoutException: Command timed out after 10 second(s) at io.lettuce.core.ExceptionFactory.createTimeoutException(ExceptionFactory.java:51) at io.lettuce.core.LettuceFutures.awaitOrCancel(LettuceFutures.java:114) at io.lettuce.core.FutureSyncInvocationHandler.handleInvocation(FutureSyncInvocationHandler.java:69) at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80) at com.sun.proxy.$Proxy110.rpop(Unknown Source) at org.springframework.data.redis.connection.lettuce.LettuceListCommands.rPop(LettuceListCommands.java:353) ... 13 more org.springframework.dao.QueryTimeoutException: Redis command timed out; nested exception is io.lettuce.core.RedisCommandTimeoutException: Command timed out after 10 second(s) at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:70) at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41) at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44) at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42) at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:270) at org.springframework.data.redis.connection.lettuce.LettuceListCommands.convertLettuceAccessException(LettuceListCommands.java:490) at org.springframework.data.redis.connection.lettuce.LettuceListCommands.rPop(LettuceListCommands.java:355) at org.springframework.data.redis.connection.DefaultedRedisConnection.rPop(DefaultedRedisConnection.java:643) at org.springframework.data.redis.core.DefaultListOperations$4.inRedis(DefaultListOperations.java:197) at org.springframework.data.redis.core.AbstractOperations$ValueDeserializingRedisCallback.doInRedis(AbstractOperations.java:60) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:228) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:188) at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96) at org.springframework.data.redis.core.DefaultListOperations.rightPop(DefaultListOperations.java:193) at com.ncs.deep.forgery.reptile.untils.RedisUtil.lrightGetRemove(RedisUtil.java:510) at com.ncs.deep.forgery.reptile.jsoup.WebSiteJsoupThread.action(WebSiteJsoupThread.java:53) at com.ncs.deep.forgery.reptile.threadabstract.RunnableFactory.run(RunnableFactory.java:15) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: io.lettuce.core.RedisCommandTimeoutException: Command timed out after 10 second(s) at io.lettuce.core.ExceptionFactory.createTimeoutException(ExceptionFactory.java:51) at io.lettuce.core.LettuceFutures.awaitOrCancel(LettuceFutures.java:114) at io.lettuce.core.FutureSyncInvocationHandler.handleInvocation(FutureSyncInvocationHandler.java:69) at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80) at com.sun.proxy.$Proxy110.rpop(Unknown Source) at org.springframework.data.redis.connection.lettuce.LettuceListCommands.rPop(LettuceListCommands.java:353) ... 13 more
线上Redis突然间出现此问题
spring boot2.x版本默认redis连接池为lettuce,而以前的jedis是没有此问题的,
所以将lettuce换成jredis,因为通过用Wireshark发现jredis默认是发心跳包的,而lettuce是不发心跳包的,所以能保持连接状态,更改如下
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <exclusions> <exclusion> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> </exclusion> <exclusion> <artifactId>lettuce-core</artifactId> <groupId>io.lettuce</groupId> </exclusion> </exclusions> </dependency> <!-- jedis客户端 --> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> </dependency> <!-- spring2.X集成redis所需common-pool2,使用jedis必须依赖它--> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> </dependency>同事
同时yml文件也要进行修改
spring: redis: port: 6379 host: 127.0.0.1 jedis: pool: max-active: 8 #连接池的最大数据库连接数。设为0表示无限制 max-wait: -1 #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。 max-idle: 8 #最大空闲数 min-idle: 0 #redis 连接超时时间ms timeout: 10000 database: 0 password:
标签:RedisCommandTimeoutException,core,java,10,redis,springframework,lettuce,org From: https://www.cnblogs.com/it1042290135/p/16877840.html