JedisConnectionException Connection Reset

本文涉及的产品
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
云数据库 Tair(兼容Redis),内存型 2GB
简介: JedisConnectionException Connection Reset 使用Jedis的subscribe进行消息订阅时有时会抛出JedisConnectionException:Connection Reset,查看redis-server控制台,发现有如下信息输出: subscribe scheduled to be closed ASAP for outcoming of output buffer limits 从字面意思来看是消息输出的缓冲区已经超出了限制,所以订阅的链接被关闭了。

JedisConnectionException Connection Reset

使用Jedis的subscribe进行消息订阅时有时会抛出JedisConnectionException:Connection Reset,查看redis-server控制台,发现有如下信息输出:

subscribe scheduled to be closed ASAP for outcoming of output buffer limits

从字面意思来看是消息输出的缓冲区已经超出了限制,所以订阅的链接被关闭了。这通常是由于消息的生产者生产的消息的速度快于消费的速度,导致消息积压,从而超出了Redis的限制。这是redis的一种自我保护机制,遇到这种情况下它就会关闭对应的连接。解决方式就是调整对应的缓冲区大小。关于缓冲区的说明在redis的配置文件redis.conf中有说明。以下是摘自其配置文件的说明。

# The client output buffer limits can be used to force disconnection of clients
# that are not reading data from the server fast enough for some reason (a
# common reason is that a Pub/Sub client can't consume messages as fast as the
# publisher can produce them).
#
# The limit can be set differently for the three different classes of clients:
#
# normal -> normal clients including MONITOR clients
# slave  -> slave clients
# pubsub -> clients subscribed to at least one pubsub channel or pattern
#
# The syntax of every client-output-buffer-limit directive is the following:
#
# client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
#
# A client is immediately disconnected once the hard limit is reached, or if
# the soft limit is reached and remains reached for the specified number of
# seconds (continuously).
# So for instance if the hard limit is 32 megabytes and the soft limit is
# 16 megabytes / 10 seconds, the client will get disconnected immediately
# if the size of the output buffers reach 32 megabytes, but will also get
# disconnected if the client reaches 16 megabytes and continuously overcomes
# the limit for 10 seconds.
#
# By default normal clients are not limited because they don't receive data
# without asking (in a push way), but just after a request, so only
# asynchronous clients may create a scenario where data is requested faster
# than it can read.
#
# Instead there is a default limit for pubsub and slave clients, since
# subscribers and slaves receive data in a push fashion.
#
# Both the hard or the soft limit can be disabled by setting them to zero.
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

笔者遇到的是由于发布/订阅的消息超出了缓冲区的大小导致的,所以需要调整client-output-buffer-limit pubsub 32mb 8mb 60。适当的调大对应的缓冲区大小即可。

相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore &nbsp; &nbsp; ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库&nbsp;ECS 实例和一台目标数据库&nbsp;RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&amp;RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
目录
相关文章
|
Java Apache 数据格式
httpclient 解决 connection reset 问题
  httpclient 解决 connection reset 问题   错误如下:   java.net.SocketException: Connection reset at java.
8811 0
|
3月前
|
网络安全
client_loop: send disconnect: Connection reset by peerB/s4-5
client_loop: send disconnect: Connection reset by peerB/s4-5
ConnectionResetError: [Errno 104] Connection reset by peer|4-16
ConnectionResetError: [Errno 104] Connection reset by peer|4-16
|
5月前
|
监控 网络安全
Connection reset by peer的原因
Connection reset by peer的原因
|
6月前
|
Linux 数据安全/隐私保护
Could not connect to ‘121.37.92.110‘ (port 22): Connection failed.
Could not connect to ‘121.37.92.110‘ (port 22): Connection failed.
|
NoSQL Redis
Lettuce: Connection to x.x.x.x not allowed. This connection point is not known in the cluster view
Lettuce: Connection to x.x.x.x not allowed. This connection point is not known in the cluster view
176 0
The transaction associated with this command is not the connection‘s active
The transaction associated with this command is not the connection‘s active
220 0
|
Java 网络安全 Docker
curl: (56) Recv failure: Connection reset by peer
curl: (56) Recv failure: Connection reset by peer
868 0
|
缓存 安全 网络安全
net::ERR_CONNECTION_RESET
`net::ERR_CONNECTION_RESET` 错误通常表示网络连接被重置。这可能是由于以下原因之一导致的: 1. 网络问题: 该错误可能是由于网络中断、不稳定的连接或基础设备故障等引起的。请确保你的网络连接正常,并尝试刷新页面或重新启动网络设备。 2. 防火墙或安全软件: 有时,防火墙或某些安全软件可能会干扰网络连接并重置它。尝试禁用防火墙或安全软件,然后再次访问网页,看看问题是否解决。 3. 代理设置: 如果你使用了代理服务器,尝试禁用代理并直接连接到互联网,然后检查问题是否仍然存在。 4. 网站服务器问题: `net::ERR_CONNECTION_RESET` 错误也可
9937 0
|
Python
ConnectionResetError: [Errno 104] Connection reset by peer
ConnectionResetError: [Errno 104] Connection reset by peer
590 0