Hi
I'm trying to setup my first RabbitMQ server, I have some python code that sends a message to localhost and it gets to the server, that is good.
I want to be able to use the code to send a message from another machine.
So I use the exact same python code to send a message and instead of localhost I have the IP address 172.17.0.1 which is the machine. (I've checked the IP address this is correct.)
(Note: At the moment everything is on the same computer but I want to be able to connect from other computers.)
But it doesn't work for IP address 172.17.0.1
What do I need to check with the server configuration?
Or is there something else I'm missing?
This is my Python:
#!/usr/bin/env python
import pika
def send_to_queue(message):
credentials = pika.PlainCredentials('test001', 'Gs3g!eJ3rb4v')
#credentials = pika.PlainCredentials('guest', 'guest')
#parameters = pika.ConnectionParameters('localhost', 5673, '/', credentials)
parameters = pika.ConnectionParameters('172.17.0.1', 5673, '/', credentials)
#parameters = pika.ConnectionParameters('amqp://172.17.0.1', 5673, '/', credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.queue_declare(queue='hello')
channel.basic_publish(exchange='', routing_key='hello',body=message)
connection.close()
return "Message Sent! "
send_to_queue("helloooo")
This is what I get when I run it.
matthew@matthew-QEMU:~/python/rabbitmq$ python3 testing_rabbitmq_003.py
Traceback (most recent call last):
File "/home/matthew/python/rabbitmq/testing_rabbitmq_003.py", line 17, in <module>
send_to_queue("helloooo")
File "/home/matthew/python/rabbitmq/testing_rabbitmq_003.py", line 10, in send_to_queue
connection = pika.BlockingConnection(parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pika/adapters/blocking_connection.py", line 360, in __init__
self._impl = self._create_connection(parameters, _impl_class)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pika/adapters/blocking_connection.py", line 451, in _create_connection
raise self._reap_last_connection_workflow_error(error)
pika.exceptions.AMQPConnectionError
matthew@matthew-QEMU:~/python/rabbitmq$
Cheers
Matthew