I am facing a puzzling (to me) problem. I have a simple sender program written in python that uses pika to send data to rabbitmq. When I start rabbitmq with no rabbitmq.conf file this sender program works fine both with the guest user and a user created in rabbitmq with a password. The code of the simple sender is below
[centos@mqserver authtest]$ cat send.py
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
with open("inputdata.txt", "r") as infile:
for line in infile:
print(line)
channel.basic_publish(exchange='', routing_key='hello', body= line)
infile.close()
connection.close()
The input data file is
[centos@mqserver authtest]$ cat inputdata.txt
line 1
line 2
line 3
When I run this it runs as expected and I see the following output on screen and a consumer is able to consume these three strings
line 1
line 2
line 3
Now when I stop rabbitmq-server and start it with the following rabbitmq.conf file
[centos@mqserver authtest]$ cat /etc/rabbitmq/rabbitmq.conf
auth_mechanisms.1 = PLAIN
auth_mechanisms.1 = AMQPLAIN
When I run the simple sender with guest user I get a pika.exceptions.AuthenticationError: PLAIN as shown below
[centos@mqserver authtest]$ python send.py
Traceback (most recent call last):
File "send.py", line 3, in <module>
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
File "/usr/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 359, in __init__
self._impl = self._create_connection(parameters, _impl_class)
File "/usr/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 450, in _create_connection
raise self._reap_last_connection_workflow_error(error)
pika.exceptions.AuthenticationError: PLAIN
[centos@mqserver authtest]$
When I run this same simple sender with an user that has been created in Rabbitmq with a password, I get the same error as shown below
[centos@mqserver authtest]$ python sendwithuser.py
Traceback (most recent call last):
File "sendwithuser.py", line 5, in <module>
connection = pika.BlockingConnection(parameters)
File "/usr/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 359, in __init__
self._impl = self._create_connection(parameters, _impl_class)
File "/usr/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 450, in _create_connection
raise self._reap_last_connection_workflow_error(error)
pika.exceptions.AuthenticationError: PLAIN
What could be the reason for this?