代码之家  ›  专栏  ›  技术社区  ›  Gav Kr

RabbitMQ-套接字关闭异常-Windows Server 2012

  •  1
  • Gav Kr  · 技术社区  · 7 年前

    所以我有一个出版商正在使用 日程

    self.connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
    self.channel = self.connection.channel()
    while True:
            method, properties, body = self.channel.basic_get(queue=conf.UNIVERSAL_MESSAGE_QUEUE, no_ack=False)
            if body is not None:
                self.assign_task(body=body)
                self.channel.basic_ack(delivery_tag=method.delivery_tag)
    
            else:
                self.logger.info('channel empty')
                self.move_to_done()
                time.sleep(5)
    

    分配任务功能如下所示:

    def assign_task(body=body):
           <do something with the message body>
    

    2017-08-03 15:27:43,756: ERROR: base_connection.py: _handle_error:   335: Socket Error: 10054
    2017-08-03 15:27:43,756: WARNING: base_connection.py: _check_state_on_disconnect:   180: Socket closed when connection was open
    2017-08-03 15:27:43,756: WARNING: connection.py: _on_disconnect:   1360: Disconnected from RabbitMQ at localhost:5672 (0): Not specified
    

    本质上,发布者和消费者都是两个不同的python程序,打算在Windows Server 2012的单机上运行。社区能否帮助了解这里可能出现的问题。
    同样的代码在我的windows机器上本地运行完全正常

    以下是我的日志文件的输出。
    =ERROR REPORT==== 3-Aug-2017::15:06:48 === closing AMQP connection <0.617.0> ([::1]:53485 -> [::1]:5672): missed heartbeats from client, timeout: 60s

    1 回复  |  直到 7 年前
        1
  •  0
  •   Gav Kr    7 年前

    对此的简单答案是创建一个持久队列,并将heartbeat_interval设置为0。