1

在 VDI 中使用 Python 3.9.5,并尝试连接 pika,但出现此错误:

    Traceback (most recent call last):
  File "C:\Users\xyz\qwert.py", line 24, in <module>
    connection = pika.BlockingConnection()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python39-32\lib\site-packages\pika\adapters\blocking_connection.py", line 360, in __init__
    self._impl = self._create_connection(parameters, _impl_class)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python39-32\lib\site-packages\pika\adapters\blocking_connection.py", line 451, in _create_connection
    raise self._reap_last_connection_workflow_error(error)
pika.exceptions.AMQPConnectionError

我使用了这段代码:

para = pika.ConnectionParameters(host='0.0.0.0', credentials=credentails)
connection = pika.BlockingConnection(para)
channel = connection.channel()
channel.queue_declare(queue=queue, durable=True)

def callback(chanel, method, properties, body):

    ch.basic_ack(delivery_tag=delivery_tag)

如何解决此错误?

4

0 回答 0