简体   繁体   English

RabbitMQ保持关闭连接

[英]RabbitMQ keeps closing connection

I'm using rabbitpy python library to interact with RabbitMQ. 我正在使用Rabbitpy python库与RabbitMQ进行交互。 I designed a communication class that have a publisher method and a consumer method. 我设计了一个具有发布者方法和使用者方法的通信类。 This communication class' instances run in separate threads. 该通信类的实例在单独的线程中运行。

If I begin frequent requests, RabbitMQ closes connection. 如果我开始频繁请求,RabbitMQ将关闭连接。 Here is the error log: 这是错误日志:

=ERROR REPORT==== 4-Apr-2014::14:12:52 ===
AMQP connection <0.13197.22> (running), channel 1 - error:
{amqp_error,unexpected_frame,
            "expected content header for class 60, got non content header frame instead",
            'basic.publish'}

=INFO REPORT==== 4-Apr-2014::14:12:52 ===
closing AMQP connection <0.13197.22> (127.0.0.1:52234 -> 127.0.0.1:5672)

=INFO REPORT==== 4-Apr-2014::14:12:52 ===
accepting AMQP connection <0.13263.22> (127.0.0.1:52237 -> 127.0.0.1:5672)

rabbitpy is a thread safe library (it says so). rabbitpy是一个线程安全的库(它是如此)。

Why am I having such a problem? 为什么会有这样的问题?

Looks like problem is multi threading. 看起来问题是多线程。 May be it's a bug in rabbitpy . 可能是rabbitpy的错误。 The solution is to either 解决方案是

  • Avoid publishing on the same channel within connection from multiple threads 避免在多个线程的连接内的同一通道上发布
  • Synchronize publishing in your own code 用您自己的代码同步发布

Check out this discussion 查看此讨论

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM