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)?