Server configuration - not just localhost

57 views
Skip to first unread message

Matthew Baynham

unread,
Nov 12, 2023, 9:39:48 AM11/12/23
to rabbitmq-users
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


Michal Kuratczyk

unread,
Nov 13, 2023, 3:26:40 AM11/13/23
to rabbitm...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/e682c026-92c8-4793-9b28-cde08a23dedfn%40googlegroups.com.


--
Michał
RabbitMQ team

Priyanka M

unread,
Nov 13, 2023, 3:29:21 AM11/13/23
to rabbitm...@googlegroups.com
How to compare rabbitmq api response with CSV file using robot framework 

Reply all
Reply to author
Forward
0 new messages