参考文献
redis 之 Connection reset by peer — blog.csdn.net
springboot链redis出现 java.io.IOException: 远程主机强迫关闭了一个现有的连接 — blog.csdn.net
nested exception is io.lettuce.core.RedisException: java.io.IOException: Connection reset by peer #1350 — github.com
解决 Error connection reset by peer — szthanatos.github.io
Ask questionscom.lambdaworks.redis.RedisException: java.io.IOException: Connection reset by peer when execute handler in thread Thread — gitmemory.com
readAddress(..) failed: Connection reset by peer #1403 — github.com
What does “connection reset by peer” mean? — stackoverflow.com
Connection reset by peer —- everything2.com
Lettuce/Lobby Chat room for the Lettuce Redis driver project — gitter.im
记录修复 Redis 的 Connection reset by peer报错 #38 — github.com
记一次Redis Lettuce连接池Connection Reset By Peer排查经历 — www.zhihengshi.com2021-02-04 16:23:56 这个问题很头疼,我查看了上面说的一些信息(说什么的都有点),上面的最后一篇文献讲的是我最同意的。
报错信息
1 | Exception in thread "KafkaTaskThread-42" org.springframework.data.redis.RedisSystemException: Redis exception; nested exception is io.lettuce.core.RedisException: java.io.IOException: Connection reset by peer |
解决方案
我的做法
把 yml 改了一下
1 | 2021-02-04 16:24:09 等待校验,暂时没问题(已经发布生产 3个小时了) |
网上方案
如果你按照我的做法
修改了 “application.yml timeout = 60000” 还不可以的话。
下面可以修改你的 Redis 服务端配置
- 修改前,我们先查看 Redis 配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23# 查看当前连接数
127.0.0.1:6379> info clients
# Clients
connected_clients:3
client_recent_max_input_buffer:8
client_recent_max_output_buffer:0
blocked_clients:0
tracking_clients:0
clients_in_timeout_table:0
# 查看超时
127.0.0.1:6379> config get time*
1) "timeout"
2) "0"
# 查看最大存活时间
127.0.0.1:6379> config get tcp*
1) "tcp-keepalive"
2) "300"
3) "tcp-backlog"
4) "511"
# 查看最大客户端数
127.0.0.1:6379> config get maxc*
1) "maxclients"
2) "10000"
- 修改 Redis 配置(临时生效,重启 Redis 失效,想持久有效可修改配置文件)
1
2
3
4
5
6
7
8# 最大连接数 3W
config set maxclients 30000
# 超时时间 300 秒
config set timeout 300
# 最大存活时间 60 秒
config set tcp-keepalive 60