Rabbitmq consumer端超时报错
0x01 应用场景:
使用rabbitmq的exchange模式,type为direct,消费端不需要向生产端返回结果no_ack=True
其中某个consumer任务耗时较长(5min以上),结果consumer端出现如下报错:
Exception in thread test:
Traceback (most recent call last):
File "D:\Program Files (x86)\python\lib\threading.py", line 530, in __bootstrap_inner
self.run()
File "E:/A_WORK/eclipse/ccin/src/main.py", line 282, in run
channel.start_consuming()
File "D:\Program Files (x86)\python\lib\site-packages\pika-0.10.0-py2.7.egg\pika\adapters\blocking_connection.py", line 1681, in start_consuming
self.connection.process_data_events(time_limit=None)
File "D:\Program Files (x86)\python\lib\site-packages\pika-0.10.0-py2.7.egg\pika\adapters\blocking_connection.py", line 647, in process_data_events
self._flush_output(common_terminator)
File "D:\Program Files (x86)\python\lib\site-packages\pika-0.10.0-py2.7.egg\pika\adapters\blocking_connection.py", line 426, in _flush_output
raise exceptions.ConnectionClosed()
ConnectionClosed
网上查了半天,发现有人说是因为consumer耗时太长,导致product和consumer之间的heartbeat断链了,考虑修改配置文件中的heartbeat时间来规避这个问题。
0x02 解决方法一:
修改rabbitmq.config
1 文件路径:
file is %APPDATA%\RabbitMQ\rabbitmq.config.
%APPDATA% usually expands to C:\Users\%USERNAME%\AppData\Roaming or similar.
见rabbit安装文件夹下的readme.txt ~~\rabbitmq_server-3.7.2\etc\README.txt
2 修改 C:\Users\%USERNAME%\AppData\Roaming\RabbitMQ\rabbitmq.config文件(将rabbitmq.config.example重命名为rabbitmq.config)
将 %% {heartbeat, 60}, 修改为 {heartbeat, 600}
去掉%% 和末尾的逗号',' 60秒修改为600秒,或自己定义的更长时间。
3 使配置生效:
cmd进入安装目录的sbin文件夹下
******\rabbitmq_server-3.7.2\sbin>
执行:rabbitmq-service.bat stop 停止服务
rabbitmq-service.bat install 重新安装服务,这时才会重新加载config文件
rabbitmq-service.bat start 开启服务
提示成功以后,再运行程序,发现就不会出现之前的异常了。
0x03 解决方法二:
在建立连接的时候就禁止心跳检测
producer端和consumer端连接初始化的时候:
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost', heartbeat_interval=0))
Rabbitmq consumer端超时报错的更多相关文章
- 【small项目】MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link ...
- redis连接超时报错
应用程序连接redis超时,报错如下: ERROR DubboServerHandler-xxx.xx.xx.52:20880-thread-172 2016-12-21 15:25:20,429 c ...
- sql server数据库查询超时报错
报错信息如下: 链接服务器"DBJointFrame"的 OLE DB 访问接口 "SQLNCLI10" 返回了消息 "查询超时已过期". ...
- vue.js使用vue-preview做移动端缩略图时报错Property or method "$preview" is not defined
报错的详细信息为: Property or method "$preview" is not defined on the instance but referenced duri ...
- wpscan 更新超时报错
wpscan更新超时报错 本人亲测方法2 https://data.wpscan.org/plugins.json https://data.wpscan.org/plugins.json.sha51 ...
- springcloud初次zuul超时报错com.netflix.zuul.exception.ZuulException:Forwarding error
报错如下 com.netflix.zuul.exception.ZuulException:Forwarding error Caused by: com.netflix.hystrix.except ...
- tomcat链接mysql时超时报错java.io.EOFException: Can not read response from server. Expected to read 4 bytes,
需要在配置文件里加上下面就ok了 <property name=”minEvictableIdleTimeMillis” value=”1800000″ /> <property n ...
- Uedior上传大文件超时报错
出错原因: 1.php超时等待时间太短 2.uedior中设置了请求超时,提示信息: 上传失败,请重试 先解决第一个问题: 设置php.ini中的max_execution_time 为0 (意思是h ...
- python Selenium chromedriver 自动化超时报错:你需要使用多标签保护罩护体
在使用selenium + chrome 作自动化测试的时候,有可能会出现网页连接超时的情况 如果出现网页连接超时,将会导致 webdriver 也跟着无法响应,不能继续进行任何操作 即时是去打开新的 ...
随机推荐
- php 常用数学函数
函数 描述 实例 输入 输出 abs() 求绝对值 $abs = abs(-4.2); //4.2 数字 绝对值数字 ceil() 进一法取整 echo ceil(9.999); // 10 浮点数 ...
- PHP正则表达式及表单注册案例
正则表达式是一种具有特定模式的用来匹配文本的字符串 preg_match 匹配 $pattern = '/php/'; $subject = "php 是最好的编程语言,php 没有之一!& ...
- win下删除EFI分区
管理员身份,在cmd终端下,用"diskpart"命令. diskpart ##命令进入Microsoft DiskPart 模式 list disk ##展示磁盘分区列表 sel ...
- 题解【洛谷P2264】情书
题面 看到每一单词在同一句话中出现多次感动值不叠加,一眼想到 \(\text{set}\). 首先将词汇列表中的单词存储起来,我用的是 \(\text{set}\). 对于每一个句子的单词,我们可以先 ...
- PP: Neural ordinary differential equations
Instead of specifying a discrete sequence of hidden layers, we parameterize the derivative of the hi ...
- jenkins Exec exit status not zero. Status [-1]
jenkins是使用ssh连接服务器后,如果使用grep获取进程并kill时,会jenkins Exec exit status not zero. Status [-1],解决办法:在获取进程时,使 ...
- mac或windows下Navicat Premium安装
找了很多地址都乱七八糟的说明一通还没啥用,好不容易找到一个靠谱的,记录一下,也方便一下和我一样苦苦寻找的人,亲测有用 https://www.52pojie.cn/thread-727433-1-1. ...
- SpringMVC 源代码深度解析 IOC容器(Bean 解析、注册)
SpringMVC通过一个配置文件描述Bean以及Bean之间的依赖关系,利用Java的反射机制实例化Bean并建立Bean之间的依赖关系.IOC容器在完成这些底层工作的基础还提供了Bean的实例缓. ...
- python之路模块
time模块 print time.time() print time.mktime(time.localtime()) print time.gmtime() #可加时间戳参数 print time ...
- 虫师自动化测试robot Framework 框架的学习2
循环的使用 1.in range和in的区别 输出结果 如果把上面的换成in range 会报错 未被定义,说明in range 后面使用的数据类型有限制,对比下,可以看出,in 可用在列表类型数据类 ...