`
234390216
  • 浏览: 10232333 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
博客专栏
A5ee55b9-a463-3d09-9c78-0c0cf33198cd
Oracle基础
浏览量:462597
Ad26f909-6440-35a9-b4e9-9aea825bd38e
springMVC介绍
浏览量:1775472
Ce363057-ae4d-3ee1-bb46-e7b51a722a4b
Mybatis简介
浏览量:1398311
Bdeb91ad-cf8a-3fe9-942a-3710073b4000
Spring整合JMS
浏览量:394999
5cbbde67-7cd5-313c-95c2-4185389601e7
Ehcache简介
浏览量:679962
Cc1c0708-ccc2-3d20-ba47-d40e04440682
Cas简介
浏览量:530847
51592fc3-854c-34f4-9eff-cb82d993ab3a
Spring Securi...
浏览量:1183873
23e1c30e-ef8c-3702-aa3c-e83277ffca91
Spring基础知识
浏览量:467818
4af1c81c-eb9d-365f-b759-07685a32156e
Spring Aop介绍
浏览量:151372
2f926891-9e7a-3ce2-a074-3acb2aaf2584
JAXB简介
浏览量:68130
社区版块
存档分类
最新评论

JedisConnectionException Connection Reset

阅读更多

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。适当的调大对应的缓冲区大小即可。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics