4

I'm trying to follow the tutorial https://www.rabbitmq.com/tutorials/tutorial-one-python.html, and have copied the commands into the following script send.py:

#!/usr/bin/env python
import pika

connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()

channel.queue_declare(queue='hello')

channel.basic_publish(exchange='', routing_key='hello', body='Hello World!')
print(" [x] Sent 'Hello Wolrd!'")

connection.close()

However, when I try to run this script, I get the following error message:

kurt@kurt-ThinkPad:~/Documents/Scratch$ python send.py
Traceback (most recent call last):
  File "send.py", line 4, in <module>
    connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 339, in __init__
    self._process_io_for_connection_setup()
  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 374, in _process_io_for_connection_setup
    self._open_error_result.is_ready)
  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 410, in _flush_output
    self._impl.ioloop.poll()
  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/select_connection.py", line 602, in poll
    self._process_fd_events(fd_event_map, write_only)
  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/select_connection.py", line 443, in _process_fd_events
    handler(fileno, events, write_only=write_only)
  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 364, in _handle_events
    self._handle_read()
  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 412, in _handle_read
    return self._handle_disconnect()
  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 288, in _handle_disconnect
    self._adapter_disconnect()
  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/select_connection.py", line 95, in _adapter_disconnect
    super(SelectConnection, self)._adapter_disconnect()
  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 154, in _adapter_disconnect
    self._check_state_on_disconnect()
  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 173, in _check_state_on_disconnect
    raise exceptions.ProbableAuthenticationError
pika.exceptions.ProbableAuthenticationError

From what I read in pika.exceptions.ProbableAuthenticationError when trying to send message to remote queue, this is because from RabbitMQ 3.3 onwards, the guest/guest username/password combination can only be used locally. The instructions to fix the problem, however, are not entirely clear to me. How would I adapt the script to create a new user (or to make it work in any other way)?

Community
  • 1
  • 1
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
  • Try to change: `pika.ConnectionParameters('localhost')` to `pika.URLParameters("amqp://guest:guest@localhost/%2f")`. – Bakuriu Oct 25 '16 at 13:21
  • [Backuriu](http://stackoverflow.com/users/510937/bakuriu), I still get a `ProbableAuthenticationError`. – Kurt Peek Oct 25 '16 at 13:34
  • I cannot reproduce your problem. Are you using different machines? – Bakuriu Oct 25 '16 at 15:46
  • 1
    A couple of days ago, I was fighting the same thing. Not sure our situations were entirely the same, but I ended up switching to amqpstorm as a python client, and my problems went away. They have good examples in their repository as well. YMMV – Travis Griggs Oct 25 '16 at 16:55
  • 1
    Have you tied to create a new user with rabbitmq web ui (management plugin) ? If not try that and use those credentials in the example (just remember to set up the permissions for the newly created user). – cantSleepNow Oct 25 '16 at 21:00

0 Answers0