Alexandre Paroissien
Alexandre Paroissien

Reputation: 647

Pika cannot consume RabbitMQ from remote IP address

I'm using Python and pika because I would like to send data with RabbitMQ from a server to another.

I followed the following tutorial to create a consumer and producer: https://www.rabbitmq.com/tutorials/tutorial-one-python.html

On the same machine, I can send messages to localhost and read from localhost and it will work.

But from a server to another it will give errors such as ConnectionClosed, ProbableAccessDeniedError, ProbableAuthenticationError

I tried to create credentials with admin access instead of using the default guest/guest credentials. I also increased the timeout from 0.25 to 2sec

 credentials = pika.credentials.PlainCredentials(server['username'], server['password'], erase_on_connect=False)

 connection = pika.BlockingConnection(pika.ConnectionParameters(host=server['ip'], credentials=credentials, socket_timeout=2))

I even tried to send and receive from the same machine, but instead of specifying 'localhost' I will provide the machine IP address, and this didn't work

Upvotes: 0

Views: 663

Answers (1)

Alexandre Paroissien
Alexandre Paroissien

Reputation: 647

I found out the issue was on the remote server hosting the producer.

The user that I created was an administrator user but was missing permissions.

Basically here is the solution (it's the third line that I initially forgot):

sudo rabbitmqctl add_user alex password
sudo rabbitmqctl set_user_tags alex administrator
sudo rabbitmqctl set_permissions -p / alex ".*" ".*" ".*"

Upvotes: 0

Related Questions