rabbitmq篇---报错解决
1.pika.exceptions.ChannelClosedByBroker: (406, “PRECONDITION_FAILED - inequivalent arg ‘x-expires’ for queue ‘source’ in vhost ‘test’: received none but current is the value ‘86400000’ of type ‘long’”)
问题代码
channel.queue_declare(queue='hello',durable=True) # durable 队列持久化
查看源码:
# def queue_declare(self, # channel.queueDeclare 用来创建队列,有5个参数:
# queue, # String queue, 队列名;
# passive=False,
# durable=False, # boolean durable, 该队列是否需要持久化
# exclusive=False, # boolean exclusive,该队列是否为该通道独占的(其他通道是否可以消费该队列)
# auto_delete=False, # boolean autoDelete,该队列不再使用的时候,是否让RabbitMQ服务器自动删除掉;
# arguments=None)
passive:是屈服的意思,将passive设为True,问题解决。
正确代码:
channel.queue_declare(queue='hello',durable=True,passive=True) # durable 队列持久化
2.ConnectionResetError: [Errno 104] Connection reset by peer
Traceback (most recent call last):File "/usr/local/lib/python3.7/site-packages/pika/adapters/utils/io_services_utils.py", line 1103, in _on_socket_writableself._produce()File "/usr/local/lib/python3.7/site-packages/pika/adapters/utils/io_services_utils.py", line 820, in _produceself._tx_buffers[0])File "/usr/local/lib/python3.7/site-packages/pika/adapters/utils/io_services_utils.py", line 79, in retry_sigint_wrapreturn func(*args, **kwargs)File "/usr/local/lib/python3.7/site-packages/pika/adapters/utils/io_services_utils.py", line 861, in _sigint_safe_sendreturn sock.send(data)
ConnectionResetError: [Errno 104] Connection reset by peer
connection_lost: StreamLostError: ("Stream connection lost: ConnectionResetError(104, 'Connection reset by peer')",)
Unexpected connection close detected: StreamLostError: ("Stream connection lost: ConnectionResetError(104, 'Connection reset by peer')",)
_AsyncBaseTransport._produce() failed, aborting connection: error=ConnectionResetError(104, 'Connection reset by peer'); sock=<socket.socket fd=138, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('172.21.0.3', 51988)>; Caller's stack:
其实原因很简单,服务端没有收到客户端的心跳包,默认是10秒,但是预计的已经超过10秒还没有发心跳包,所以服务端主动断连了。
class ConnectionParameters(Parameters):"""Connection parameters object that is passed into the connection adapterupon construction."""# Protect against accidental assignment of an invalid attribute__slots__ = ()class _DEFAULT(object):"""Designates default parameter value; internal use"""def __init__( # pylint: disable=R0913,R0914self,host=_DEFAULT,port=_DEFAULT,virtual_host=_DEFAULT,credentials=_DEFAULT,channel_max=_DEFAULT,frame_max=_DEFAULT,heartbeat=_DEFAULT,ssl_options=_DEFAULT,connection_attempts=_DEFAULT,retry_delay=_DEFAULT,socket_timeout=_DEFAULT,stack_timeout=_DEFAULT,locale=_DEFAULT,blocked_connection_timeout=_DEFAULT,client_properties=_DEFAULT,tcp_options=_DEFAULT,**kwargs):"""Create a new ConnectionParameters instance. See `Parameters` fordefault values.:param str host: Hostname or IP Address to connect to:param int port: TCP port to connect to:param str virtual_host: RabbitMQ virtual host to use:param pika.credentials.Credentials credentials: auth credentials:param int channel_max: Maximum number of channels to allow:param int frame_max: The maximum byte size for an AMQP frame:param int|None|callable heartbeat: Controls AMQP heartbeat timeout negotiationduring connection tuning. An integer value always overrides the valueproposed by broker. Use 0 to deactivate heartbeats and None to alwaysaccept the broker's proposal. If a callable is given, it will be calledwith the connection instance and the heartbeat timeout proposed by brokeras its arguments. The callback should return a non-negative integer thatwill be used to override the broker's proposal.:param `pika.SSLOptions`|None ssl_options: None for plaintext or`pika.SSLOptions` instance for SSL/TLS. Defaults to None.:param int connection_attempts: Maximum number of retry attempts:param int|float retry_delay: Time to wait in seconds, before the next:param int|float socket_timeout: Positive socket connect timeout inseconds.:param int|float stack_timeout: Positive full protocol stack(TCP/[SSL]/AMQP) bring-up timeout in seconds. It's recommended toset this value higher than `socket_timeout`.:param str locale: Set the locale value:param int|float|None blocked_connection_timeout: If not None,the value is a non-negative timeout, in seconds, for theconnection to remain blocked (triggered by Connection.Blocked frombroker); if the timeout expires before connection becomes unblocked,the connection will be torn down, triggering the adapter-specificmechanism for informing client app about the closed connection:passing `ConnectionBlockedTimeout` exception to on_close_callbackin asynchronous adapters or raising it in `BlockingConnection`.:param client_properties: None or dict of client properties used tooverride the fields in the default client properties reported toRabbitMQ via `Connection.StartOk` method.:param tcp_options: None or a dict of TCP options to set for socket"""super(ConnectionParameters, self).__init__()
在py3:ConnectionParameters设置heartbeat_interval=0即可。
在py2:ConnectionParameters设置heartbeat=0即可。
rabbitmq篇---报错解决相关推荐
- Linux Lernel Panic 报错解决思路
Linux Kernel Panic 报错解决思路 作为系统管理员面对server重启都起不来,那是一个相当烦躁,接显示器查看经常会碰到遇到这样的字眼"Kernel Panic" ...
- oracle拼接字符串报错,Oracle 中wmsys.wm_concat拼接字符串,结果过长报错解决
备忘:这个函数最大是4000,根据拼接列的长度,通过限制拼接条数来防止拼接字符串过长错误 --这个情况是从子表中读取出具,这里直接把它当做查询字段处理,在子表中有所有数据 select info.id ...
- php的old函数,laravel单元测试之phpUnit中old()函数报错解决
php 的 laravel单元测试之phpUnit中old()函数报错解决 前言 最近在做laravel单元测试.遇到了一个问题: 当添加的view里面使用old()函数时就会报错,正常url访问没问 ...
- 常见Eclipse SVN插件报错解决方法
名师指导: 常见Eclipse SVN插件报错解决方法 在学习SVN的过程中,你经常会遇到SVN插件问题,本文介绍一下在安装SVN插件时常见Eclipse SVN插件报错信息问题,希望本文介绍对你的学 ...
- Windows上pip install kenlm报错解决
Windows上pip install kenlm报错解决 解决办法1: 一般在windows上安装kenlm会遇到与Microsoft Visual C++ 14.0 is required相关的问 ...
- 高翔视觉SLAM十四讲(第二版)各种软件、库安装的以及报错解决方法
目录 前言 系统版本 下载高翔视觉SLAM十四讲第二版的源代码 一.安装 Vim 二.安装 g++ 三.安装 KDevelop 以及汉化 1.安装 2.汉化 四.安装 Eigen 库 五.安装 Pan ...
- Hbase报错解决方法ERROR: KeeperErrorCode = NoNode for /hbase/master
步骤 今天搭建Hbase环境,遇到了此bug.一开始搭建hdfs的时候还是很顺利的,参考着别人的博客,一步一的做下去,最后可以正常启动.而在搭建HBase的时候遇到了一个很大的bug.但是造成该bug ...
- Communication error with Jack server , try ‘jack-diagnose‘ or see Jack server log 报错解决办法
创作不易,请尊重原创,转载注明出处: https://blog.csdn.net/An_Times/article/details/121334749 Communication error with ...
- unplugin-auto-import的配置和eslint报错解决
unplugin-auto-import的配置和eslint报错解决 先上官网:unplugin-auto-import unplugin-auto-import 解决了vue3-hook.vue-r ...
最新文章
- GBDT家族:GBDT家族成员的演进路劲、xgboost模型、lightGBM、LightGBM 相对于 XGBoost 的优点、catboost、xgboost、catboost、lightGBM对
- mac改终端前面的计算机名
- 【机器学习】用PyCaret创建整个机器学习管道
- 基于事件驱动架构构建微服务第13部分:使用来自Apache KAFKA的事件并将投影流传输到ElasticSearch...
- 【Servlet】过滤器技术
- Java之消息摘要之commons codec
- C#开发:openfiledialog的使用
- HTML5+学习笔记2-------边看代码边研究貌似还是有点问题...还在研究中api中
- mysql+web日志分析工具_用Python+MySQL实现2017年web日志分析报告
- python从入门到精通需要多久-Python从入门到精通只需要一个月就够了!
- php连接mysql的方式_php连接mysql的三种方式
- 源码编译CWM Recovery
- SERC2013 J You Win!
- 使用 C# 编程对 RTF 文档进行操作 [转载]
- 计算机网各管理员技能鉴定,计算机网络管理员国家职业技能鉴定考核指导
- 前端工作中遇到的问题总结(一)
- Matlab中pickic_高颜值甜品DIY |春季甜品Picnic野餐系列,一起过个惬意慵懒的午后时光❗️...
- 什么是Power BI?
- DevOps落地实践:普元:PRIMETON DEVOPS
- android融云消息免打扰