gpt4 book ai didi

python - pika向rabbitmq发送消息超时

转载 作者:行者123 更新时间:2023-11-28 19:22:28 25 4
gpt4 key购买 nike

当尝试使用 pika 和 rabbitmq 将消息从笔记本电脑发送到另一台笔记本电脑时,出现此错误。有什么解决办法吗?

WARNING:pika.adapters.base_connection:Could not connect due to "timeout," retrying in 2 sec
ERROR:pika.adapters.base_connection:Could not connect: timeout
Traceback (most recent call last):
File "C:/Users/Peter/Desktop/Blimp182-development(1)/Blimp182-development/Blimp182/send.py", line 7, in <module>
connection = pika.BlockingConnection(parameters)
File "C:\Python27\lib\site-packages\pika\adapters\base_connection.py", line 61, in __init__
super(BaseConnection, self).__init__(parameters, on_open_callback)
File "C:\Python27\lib\site-packages\pika\connection.py", line 513, in __init__
self._connect()
File "C:\Python27\lib\site-packages\pika\connection.py", line 804, in _connect
self._adapter_connect()
File "C:\Python27\lib\site-packages\pika\adapters\blocking_connection.py", line 138, in _adapter_connect
super(BlockingConnection, self)._adapter_connect()
File "C:\Python27\lib\site-packages\pika\adapters\base_connection.py", line 120, in _adapter_connect
self.params.retry_delay)
pika.exceptions.AMQPConnectionError: 2.0

进程结束,退出代码为 1

使用的代码在这里:

import pika
import logging
logging.basicConfig()
credentials = pika.PlainCredentials('guest','guest')
parameters = pika.ConnectionParameters('10.43.12.76', 55672, '/', credentials)
connection = pika.BlockingConnection(parameters=parameters)
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()

最佳答案

我不确定您使用的是哪个版本的 RabbitMQ,但端口 55672 用于 3.0 之前的版本。对于较新的版本,使用 5672。我知道不久前有人问过这个问题,但 3.0 是在 2012 年发布的。这很可能是您超时问题的原因。

关于python - pika向rabbitmq发送消息超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21811299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com