个人解决方法:
编辑/etc/ssh/sshd_config,添加配置项:
ClientAliveInterval 600
ClientAliveCountMax 10
配置完后保存,重启服务:
service sshd restart
以下是整个经过:
本地开发是发现隔一段时间没请求redis就会报错:
2020/07/09 10:31:35 ERROR [com.SpringLearn.common.redis.JedisUtils] - Redis exception; nested exception is io.lettuce.core.RedisException: java.io.IOException: 远程主机强迫关闭了一个现有的连接。
org.springframework.data.redis.RedisSystemException: Redis exception; nested exception is io.lettuce.core.RedisException: java.io.IOException: 远程主机强迫关闭了一个现有的连接。
at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:74)
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:268)
at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.convertLettuceAccessException(LettuceStringCommands.java:799)
at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.get(LettuceStringCommands.java:68)
at org.springframework.data.redis.connection.DefaultedRedisConnection.get(DefaultedRedisConnection.java:253)
at org.springframework.data.redis.core.DefaultValueOperations$1.inRedis(DefaultValueOperations.java:57)
at org.springframework.data.redis.core.AbstractOperations$ValueDeserializingRedisCallback.doInRedis(AbstractOperations.java:59)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:224)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184)
at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:95)
at org.springframework.data.redis.core.DefaultValueOperations.get(DefaultValueOperations.java:53)
at com.SpringLearn.common.redis.JedisUtils.get(JedisUtils.java:114)
at com.SpringLearn.common.framework.securi
网上看了很多解决办法,都是timeout和tcp-keepalive的配置,多次试验后都无效,最奇怪的是putty链接服务器也是过一会就断开了,mysql出现了这种情况,于是猜测不是redis的配置问题,开启本地虚拟机测试发现没有出现断开链接的问题,查了putty自动断开链接的解决方案(文章开头),修改完后上面的问题竟然解决了,本地服务的输出日志出现了下面的日志:文章来源:https://www.toymoban.com/news/detail-660716.html
2020/07/09 20:20:02 INFO [io.lettuce.core.protocol.ConnectionWatchdog] - Reconnecting, last destination was /139.xxx.xx.xx:6666
2020/07/09 20:20:03 INFO [io.lettuce.core.protocol.ReconnectionHandler] - Reconnected to 139.xxx.xx.xx:6666
2020/07/09 20:20:03 INFO [io.lettuce.core.protocol.ConnectionWatchdog] - Reconnecting, last destination was /139.xxx.xxx.xx:6666
2020/07/09 20:20:03 INFO [io.lettuce.core.protocol.ReconnectionHandler] - Reconnected to 139.xxx.xxx.xxx:6666
可以看出连接池每隔一段时间在重新链接到redis,不知道什么原因,希望有大佬解答 Thanks(?ω?)?文章来源地址https://www.toymoban.com/news/detail-660716.html
到了这里,关于Redis exception; nested exception is io.lettuce.core.RedisException java.io.IOException 远程主机的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!