2

我刚刚设置了 CentOS 6.3 的全新 VMWare 安装。互联网正在运行,一切似乎都可以正常运行。

我正在尝试使用 RabbitMQ,但我被困在他们教程的第 1 步:

http://www.rabbitmq.com/tutorials/tutorial-one-python.html

基本上,我:

  1. 设置 Linux 实例
  2. 安装了 RabbitMQ 的所有依赖项,例如 erlang/esel
  3. 尝试他们的 Hello World 教程

它实际上在这一行失败了:

import pika
pika.BlockingConnection()

我收到此错误:

> Traceback (most recent call last):   File "<stdin>", line 1, in
> <module>   File
> "/usr/lib/python2.6/site-packages/pika/adapters/blocking_connection.py",
> line 33, in __init__
>     BaseConnection.__init__(self, parameters, None, reconnection_strategy)   File
> "/usr/lib/python2.6/site-packages/pika/adapters/base_connection.py",
> line 50, in __init__
>     reconnection_strategy)   File "/usr/lib/python2.6/site-packages/pika/connection.py", line 170, in
> __init__
>     self._connect()   File "/usr/lib/python2.6/site-packages/pika/connection.py", line 228, in
> _connect
>     self.parameters.port or  spec.PORT)   File "/usr/lib/python2.6/site-packages/pika/adapters/blocking_connection.py",
> line 37, in _adapter_connect
>     BaseConnection._adapter_connect(self, host, port)   File "/usr/lib/python2.6/site-packages/pika/adapters/base_connection.py",
> line 58, in _adapter_connect
>     self.socket.connect((host, port))   File "<string>", line 1, in connect socket.error: 
[Errno 111] Connection refused

我正在尝试我所有的故障排除尝试,我有点期待其他人也有同样的问题并发布了它。哦,好吧,我猜我是第一个!

无论如何,在这一点上,我认为我没有接触过 RabbitMQ 库,所以这可能只是一个 Pika 问题。

以下是我从 Wireshark 看到的,专注于 127.0.0.1:

1   0.000000    127.0.0.1   127.0.0.1   TCP 58748 > amqp [SYN] Seq=0 Win=32792 Len=0 MSS=16396 TSV=41371814 TSER=0 WS=6
2   0.000079    127.0.0.1   127.0.0.1   TCP amqp > 58748 [RST, ACK] Seq=1 Ack=1 Win=0 Len=0

我可以从wireshark提供更多信息,请告诉我

4

1 回答 1

3

[RST, ACK]序列看起来像是被拒绝的连接,但可能会产生误导。我假设安装rabbitmq服务后正确启动并且您可以运行rabbitmqctl status并获得合理的结果?如果它没有运行,那么你可能需要/sbin/service rabbitmq-server start先运行。

Assuming you've got the broker running, the next thing I would suggest is opening up the RabbitMQ logs - if you're not sure about the location then consult the relevant documentation - to see if the connection is being allowed. If the connection isn't logged (and you've not modified the log levels) then what you're seeing might be some other software (such as a firewall, iptables, etc) preventing connectivity.

于 2013-03-06T19:47:34.923 回答