繁体   English   中英

程序运行 Pika 抛出 AMQPConnectionError

[英]Program Running Pika Throwing AMQPConnectionError

通过此处找到的 Rabbit MQ Pika HelloWorld 教程: https : //www.rabbitmq.com/tutorials/tutorial-one-python.html

问题是,每当我运行接收脚本时,我都会收到此错误:

Traceback (most recent call last):
  File "receive.py", line 5, in <module>
    pika.ConnectionParameters(host='localhost'))

  File "C:\Users\Colin Warn\PycharmProjects\untitled2\venv\lib\site-packages\pika\adapters\blocking_connection.py", line 360, in __init__
    self._impl = self._create_connection(parameters, _impl_class)

  File "C:\Users\Colin Warn\PycharmProjects\untitled2\venv\lib\site-packages\pika\adapters\blocking_connection.py", line 451, in _create_connection
 
raise self._reap_last_connection_workflow_error(error)

pika.exceptions.AMQPConnectionError

这是我试图运行的代码:

#!/usr/bin/env python
import pika

connection = pika.BlockingConnection(
    pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

channel.queue_declare(queue='hello')


def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)


channel.basic_consume(
    queue='hello', on_message_callback=callback, auto_ack=True)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()

任何帮助深表感谢。 非常感谢你提前。

浏览Rabbit MQ Pika HelloWorld教程,网址为: https : //www.rabbitmq.com/tutorials/tutorial-one-python.html

问题是,每当我运行接收脚本时,我都会不断收到此错误:

“追踪(最近一次通话最近一次):文件“ receive.py”,第5行,位于pika.ConnectionParameters(host ='localhost'))

文件“ C:\\ Users \\ Colin Warn \\ PycharmProjects \\ untitled2 \\ venv \\ lib \\ site-packages \\ pika \\ adapters \\ blocking_connection.py”, init self._impl = self._create_connection(参数,_impl_class)

文件“ C:\\ Users \\ Colin Warn \\ PycharmProjects \\ untitled2 \\ venv \\ lib \\ site-packages \\ pika \\ adapters \\ blocking_connection.py”,行451,_create_connection

提高自我._reap_last_connection_workflow_error(错误)

pika.exceptions.AMQPConnectionError“

这是我尝试运行的代码:

#!/usr/bin/env python
import pika

connection = pika.BlockingConnection(
    pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

channel.queue_declare(queue='hello')


def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)


channel.basic_consume(
    queue='hello', on_message_callback=callback, auto_ack=True)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()

任何帮助深表感谢。 提前非常感谢您。

浏览Rabbit MQ Pika HelloWorld教程,网址为: https : //www.rabbitmq.com/tutorials/tutorial-one-python.html

问题是,每当我运行接收脚本时,我都会不断收到此错误:

“追踪(最近一次通话最近一次):文件“ receive.py”,第5行,位于pika.ConnectionParameters(host ='localhost'))

文件“ C:\\ Users \\ Colin Warn \\ PycharmProjects \\ untitled2 \\ venv \\ lib \\ site-packages \\ pika \\ adapters \\ blocking_connection.py”, init self._impl = self._create_connection(参数,_impl_class)

文件“ C:\\ Users \\ Colin Warn \\ PycharmProjects \\ untitled2 \\ venv \\ lib \\ site-packages \\ pika \\ adapters \\ blocking_connection.py”,行451,_create_connection

提高自我._reap_last_connection_workflow_error(错误)

pika.exceptions.AMQPConnectionError“

这是我尝试运行的代码:

#!/usr/bin/env python
import pika

connection = pika.BlockingConnection(
    pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

channel.queue_declare(queue='hello')


def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)


channel.basic_consume(
    queue='hello', on_message_callback=callback, auto_ack=True)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()

任何帮助深表感谢。 提前非常感谢您。

按着这些次序:

  1. 须藤 apt-get 安装 rabbitmq-server
  2. 须藤 systemctl 启动 rabbitmq-server
  3. 须藤 systemctl 启用 rabbitmq-server

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM