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. 牛客网 —— 爱奇艺2020校招C++方向笔试题 总结

    错了5,6个,主要集中在数据库和操作系统上.    C++还需要提高熟练度. 总结 第6题: 折半查找树:根据二分查找构造得到的树,它一定是一个二叉排序树,是一个特殊的二叉排序树.  (接近于平衡二叉 ...

  2. 记一个js toUpperCase函数 大小写特性

    toUpperCase()是javascript中小写变大写的函数 "ı".toUpperCase() == 'I',"ſ".toUpperCase() == ...

  3. MySQL的联表查询

    MySQL的联表查询 首选:分析查询的字段来自哪些表 进而:确定交集 然后:确定判断的条件 比如:从student表 和 result表 查学号.考试名称.学时.考试日期.考试成绩 表1: 学号 考试 ...

  4. Dijkstra算法依据项目改进版,输出路径

    package dijkstra; import java.util.ArrayList; public class Dijkstra { ; /*private static int[][] Gra ...

  5. TensorFlow入门(常量变量及其基本运算)

    1.tensorflow常量变量的定义 测试代码如下: # encoding:utf-8 # OpenCV tensorflow # 类比 语法 api 原理 # 基础数据类型 运算符 流程 字典 数 ...

  6. 6.Dockerfile 指令

    概述 我们已经介绍了 FROM,RUN,还提及了 COPY, ADD,其实 Dockerfile 功能很强大,它提供了十多个指令.下面我们继续讲解其他的指令. COPY 格式: COPY <源路 ...

  7. Wannafly Camp 2020 Day 1A 期望逆序对 - 概率期望

    分类讨论即可 #include <bits/stdc++.h> using namespace std; #define int long long const int N = 5005; ...

  8. Namespace declaration statement has to be the very first statement or after

    解决办法:将页面文件转为utp-8无dom格式就OK了.以notepad++为例:

  9. vue formatter element表格处理数据

    formatter 指定一个vue methods 方法 作用:对从数据库中取出的数据进行处理后展示. <el-table-column prop="partner1" // ...

  10. 在Unity5中使用C#脚本实现UI的下滑、变色、渐隐渐现效果

    一.首先,我们先创建一个Text    依次选择Component→UI→Text创建一个Text,创建完成后如下: 二.创建完成后,在Project面板点击Create→C# Script,本例命名 ...