博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JedisConnectionException Connection Reset
阅读量:7105 次
发布时间:2019-06-28

本文共 2231 字,大约阅读时间需要 7 分钟。

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 
## 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 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60

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

转载地址:http://ejjhl.baihongyu.com/

你可能感兴趣的文章
MySQL冗余数据的三种方案
查看>>
浅谈centos7的lvm(pv,vg,lv)
查看>>
caj怎么转word文档
查看>>
找出10000内数字等于各位数字的四次方之和
查看>>
数据库中的事务、视图、序列 、同义词、索引、数据字典、PL/SQL块 、异常处理、存储过程...
查看>>
IT兄弟连 JavaWeb教程 JSP中的注释
查看>>
Linux-yum源
查看>>
『面向工资跳槽?』——写给在考虑新机会的你
查看>>
Oracle性能参数—经典常用
查看>>
SQL SERVER BACKUP DATABASE 加快备份速度方法(压缩-Compression)
查看>>
网络设备为了方便管理的配置
查看>>
nginx 添加 ssl模块
查看>>
Linux之搭建memcache缓存服务器(二)
查看>>
Python3.5修炼手册3
查看>>
通过数据库来显示迁移文章
查看>>
IPv4地址
查看>>
X Window 系统的窗口显示原理
查看>>
我的友情链接
查看>>
win2003 自动注销已经断开的会话,已防止共享文件被他人编辑而不能修改
查看>>
CentOS 7.0 安装jdk-7u79-linux-x64.tar.gz 新手推荐
查看>>