RabbitMQ Declare Exchange from Terminal - Access refused: /api/exchanges/
Asked Answered
R

3

28

I'm using rabbitmq to handle messages between my databases for an enterprise application I work on. As part of the process, I'm trying to help automate the setup of the servers (e.g. script it). In this process, I've tried to use rabbitmqadmin to declare exchanges from the command prompt. I have 2 different servers running CentOS 5.x and CentOS 6.x and both are having the same issue.

So far I declared an administrator user and set its password, then I set its tag to be of the administrator tag, then I ensure it has permissions to the vhosts. After that I try to declare the exchange, with user and password specified and it fails.

rabbitmqctl add_user administrator password
rabbitmqctl set_user_tags administrator administrator
rabbitmqctl set_permissions -p / administrator ".*" ".*" ".*"
rabbitmqctl add_vhost vhostFoo
rabbitmqctl set_permissions -p vhostFoo administrator ".*" ".*" ".*"
rabbitmqadmin -u administrator -p password declare exchange --vhost=vhostFoo name=exchangeNew type=direct

For the CentOS 5.x box I have to use python26 rabbitmqadmin instead of just rabbitmqadmin, but get the same result.

The last command results in:

*** Access refused: /api/exchanges/vhostFoo/exchangeNew

Both my CentOS 5.x and Cent 6.x boxes are running rabbitmq 3.3.5. Any thoughts on what I'm missing or thoughts on how I can get more info on what's wrong (e.g. error log file or way to get more verbose output)?

Romaine answered 1/10, 2014 at 16:0 Comment(0)
R
44

I figured out my issue and wanted to post the answer in case someone else comes across the same issue. I checked out my /var/log/rabbitmq/ and the last bit showed access to my vhostFoo was refused for user 'guest'. Based on this, it made me think that my order of params was incorrect, which it looks to be the case. I used the following and it worked fine:

rabbitmqadmin declare exchange --vhost=vhostFoo name=exchangeNew type=direct -u administrator -p password 
Romaine answered 1/10, 2014 at 16:17 Comment(1)
Apparently rabbitmqadmin now needs username and password set for whichever command we choose to execute... and that's a good thing!Cottontail
T
6

Adding user and password (-u administrator -p password) of administrator user to the command worked for me.

Thalassography answered 23/3, 2020 at 14:28 Comment(0)
G
0

You can add the user with administrator rights locally on your system. Type http://localhost:15672/#/ in your browser. In that Admin tab, you can create a user with admin rights.

Grigsby answered 5/6, 2017 at 5:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.