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端超时报错的更多相关文章

  1. 【small项目】MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:

    MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link ...

  2. redis连接超时报错

    应用程序连接redis超时,报错如下: ERROR DubboServerHandler-xxx.xx.xx.52:20880-thread-172 2016-12-21 15:25:20,429 c ...

  3. sql server数据库查询超时报错

    报错信息如下: 链接服务器"DBJointFrame"的 OLE DB 访问接口 "SQLNCLI10" 返回了消息 "查询超时已过期". ...

  4. vue.js使用vue-preview做移动端缩略图时报错Property or method "$preview" is not defined

    报错的详细信息为: Property or method "$preview" is not defined on the instance but referenced duri ...

  5. wpscan 更新超时报错

    wpscan更新超时报错 本人亲测方法2 https://data.wpscan.org/plugins.json https://data.wpscan.org/plugins.json.sha51 ...

  6. springcloud初次zuul超时报错com.netflix.zuul.exception.ZuulException:Forwarding error

    报错如下 com.netflix.zuul.exception.ZuulException:Forwarding error Caused by: com.netflix.hystrix.except ...

  7. tomcat链接mysql时超时报错java.io.EOFException: Can not read response from server. Expected to read 4 bytes,

    需要在配置文件里加上下面就ok了 <property name=”minEvictableIdleTimeMillis” value=”1800000″ /> <property n ...

  8. Uedior上传大文件超时报错

    出错原因: 1.php超时等待时间太短 2.uedior中设置了请求超时,提示信息: 上传失败,请重试 先解决第一个问题: 设置php.ini中的max_execution_time 为0 (意思是h ...

  9. python Selenium chromedriver 自动化超时报错:你需要使用多标签保护罩护体

    在使用selenium + chrome 作自动化测试的时候,有可能会出现网页连接超时的情况 如果出现网页连接超时,将会导致 webdriver 也跟着无法响应,不能继续进行任何操作 即时是去打开新的 ...

随机推荐

  1. vsftpd最详细的配置文件

    vsftpd作为一个主打安全的FTP服务器,有很多的选项设置.下面介绍了vsftpd的配置文件列表,而所有的配置都是基于vsftpd.conf这个配置文件的.本文将提供完整的vsftpd.conf的中 ...

  2. Vue前端挂载对象时一些思考

    最近,在Vue前端调试http请求,无论如何如何也是拦截不了某些http请求.场景是这样的:Java后端组装好Vue对象,然后送到前端,前端通过id来挂载该Vue对象,而该对象中有上传文件或者图片的控 ...

  3. 百度网盘无vip高速下载的方法

    我拿的是谷歌浏览器做实验 首先下载一个可以改user-agent的插件 我chorm里面下载的是User-Agent Switcher for Chrome插件 将百度网盘的url地址中的baidu. ...

  4. Codeforces 832A. Sasha and Sticks

    It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day h ...

  5. 微信小程序:如何判断数组中的条数?

    可以<view wx:if="{{list.length == 0}}"> </view> 可以在 {{}} 内进行简单的运算,包括三元运算符.逻辑判断.算 ...

  6. 转载:dsp芯片的定点运算

    转自: http://ishare.iask.sina.com.cn/f/37179153.html

  7. hive删除表时直接卡死

    原因:因为以前安装的mysql,字符集都改为了utf-8. 解决方案:需要把字符集都改为latin1 首先进入mysql查看字符集 show variables like 'char%' 找到mysq ...

  8. Java单体应用 - 架构模式 - 02.MVC架构

    原文地址:http://www.work100.net/training/monolithic-architecture-mvc.html 更多教程:光束云 - 免费课程 MVC架构 序号 文内章节 ...

  9. appium+android测试环境安装

    1. jdk配置 一.背景 JDK已经更新到12了,但是由于很多工具仍然未及时更新,故推荐最稳定的JDK版本1.8.x: JDK需要配置通常情况下,JDK配置分为三项: JAVA_HOME:某些软件仍 ...

  10. 3ds Max File Format (Part 2: The first inner structures; DllDirectory, ClassDirectory3)

    Now that we understand the outer structure of the file, it's time to look closer to what's inside. T ...