如何使用rabbitmq连接两台电脑

时间:2016-06-06 11:23:58

标签: rabbitmq

追踪(最近一次呼叫最后一次):

  File "C:/Python27/Scripts/send.py", line 4, in <module>
    host='192.168.1.11'))
  File "C:\Python27\lib\site-packages\pika\adapters\blocking_connection.py", line 339, in __init__
    self._process_io_for_connection_setup()
  File "C:\Python27\lib\site-packages\pika\adapters\blocking_connection.py", line 374, in _process_io_for_connection_setup
    self._open_error_result.is_ready)
  File "C:\Python27\lib\site-packages\pika\adapters\blocking_connection.py", line 395, in _flush_output
    raise exceptions.ConnectionClosed()
ConnectionClosed

这是我在使用rabbitmq连接两台笔记本电脑时遇到的错误。我给了ipaddress代替本地主机。

import pika

connection = pika.BlockingConnection(pika.ConnectionParameters(
    host='ip address of receiver'))
channel = connection.channel()

channel.queue_declare(queue='hello')

channel.basic_publish(exchange='',
                  routing_key='hello',
                  body='Hello World!')
print(" [x] Sent 'Hello World!'")
connection.close()

0 个答案:

没有答案