Going through the Rabbit MQ Pika HelloWorld tutorial found here: https://www.rabbitmq.com/tutorials/tutorial-one-python.html
The problem is, I keep getting this error whenever I run my receive script:
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
Here's the code I'm attempting to run:
#!/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()
Any help is much appreciated. Thank you so much in advance.
All you need to do is installing RabbitMQ in your PC. You can simply run with docker using the command below in another terminal, and re-run your code
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
You need to install RabbitMQ on your machine: https://rabbitmq.com/download.html
After installing RabbitMQ server re-run the script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With