RabbitMQ 的连接错误

Connection error for RabbitMQ

我对 MQ 和 pika 完全陌生。

当我尝试执行此代码(服务器代码)时出现错误: (对于接收者代码,我也遇到了同样的错误。)

import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(
     host="localhost:5672"))
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()

错误:

Traceback (most recent call last):
File "D:\Workspace\Luna_WS\MQ\RabbitMQ\Sample\Src\Sample.py", line 10, in <module>
host="localhost:5672"))
File "C:\Python34\lib\site-packages\pika\adapters\blocking_connection.py", line 339, in __init__
self._process_io_for_connection_setup()
File "C:\Python34\lib\site-packages\pika\adapters\blocking_connection.py", line 374, in _process_io_for_connection_setup
self._open_error_result.is_ready)
File "C:\Python34\lib\site-packages\pika\adapters\blocking_connection.py", line 395, in _flush_output
raise exceptions.ConnectionClosed()
pika.exceptions.ConnectionClosed

我安装了:(使用 windows 7、32 位)

pikka 包 - pika-0.10.0-py2.py3-none-any.whl

二郎 - esl-erlang_18.2-1-windows_i386

RabbitMq 服务器 - rabbitmq-server-3.6.0

尝试将主机拆分为单独的主机和端口连接参数:

connection = pika.BlockingConnection(
                 pika.ConnectionParameters(host="localhost", port=5672))