amqpstorm连接超时

时间:2017-09-06 08:22:40

标签: python rabbitmq amqpstorm

我在myserver.com上的docker容器中运行了兔子

我尝试了https://github.com/eandersson/amqpstorm中的示例,但在尝试连接到远程兔子时,我的连接超时了。

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-
    packages/amqpstorm/connection.py", line 70, in __init__
self.open()
  File "/usr/local/lib/python3.5/dist-
packages/amqpstorm/connection.py", line 192, in open
    self._wait_for_connection_state(state=Stateful.OPEN)
  File "/usr/local/lib/python3.5/dist-packages/amqpstorm/connection.py", 
line 315, in _wait_for_connection_state
raise AMQPConnectionError('Connection timed out')
amqpstorm.exception.AMQPConnectionError: Connection timed out

我使用的代码是:

from amqpstorm import Connection
from amqpstorm.exception import AMQPConnectionError

try:
    with Connection('myserver.com', 'username', 'password') as connection:

        with connection.channel() as channel:

            channel.queue.declare("my_queue")

            properties = {
                'content_type': 'text/plain',
                'headers': {'key': 'value'}
            }

            channel.basic.publish(body="Hello World",
                              routing_key="my_queue",
                              properties=properties)
except AMQPConnectionError as e:
    print(e)

如果我在本地设置兔子并连接到127.0.0.1,这是有效的。 远程计算机上的Rabbit启动并运行,我可以从myserver.com:55672访问。

我也尝试将端口设置为参数而没有效果。

0 个答案:

没有答案