Search code examples
rabbitmqpikarabbitmqctlpython-pika

Unable to access RabbitMQ server from other clients on the network due to authentication error


I have installed RabbitMQ on Ubuntu 14.04 and I am unable to connect to the RabbitMQ server from other computers on the network.

There are no problems connecting to the server from the machine where RabbitMQ is installed, only from other computers on the network.

This page states that "By default, RabbitMQ will listen on port 5672 on all available interfaces".

When trying to connect from another serverusing pika in python, I get the following error:

ERROR:pika.adapters.base_connection:Socket Error: 104
ERROR:pika.adapters.base_connection:Socket closed while authenticating indicating a probable authentication error

I've added a new user with permissions set_permissions newuser ".*" ".*" ".*" and have tried the URI authentication method however I still receive the same error.

I also can't connect to RabbitMQ management from other computers on the network but can access it on the local pc.

Also, by checking open ports, I can see the following:

tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      1122/beam.smp   
tcp        0      0 0.0.0.0:15672           0.0.0.0:*               LISTEN      1122/beam.smp   
tcp6       0      0 :::5672                 :::*                    LISTEN      1122/beam.smp   

I am using the python code from RabbitMQ's tutorials:

import pika

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

channel.queue_declare(queue='hello')

channel.basic_publish(exchange='',routing_key='hello',body='Hello World!')

print(" [x] Sent 'Hello World!'")

connection.close()

What am I missing?


Solution

  • The code in question doesn't supply a username or password. You'll likely need to update your connection parameters to include those

    
    credentials = pika.PlainCredentials('guest', 'guest')
    
    parameters = pika.ConnectionParameters('rabbit-server1', 5672, '/', credentials)
    
    connection = pika.BlockingConnection(parameters)
    

    Check the docs for pika, for more info: http://pika.readthedocs.org/en/0.10.0/modules/parameters.html?highlight=connectionParameters

    Also, check to ensure you have a valid username and password. the "guest" username / password may not be enabled on your server