Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot connect to RabbitMQ on Heroku with pika due to ProbableAccessDeniedError

I just set up a RabbitMQ add-on in heroku. After developing my app to queue up and consume messages running on a local instance, I deployed it to Heroku and have not been able to connect successfully yet. The username/password & hostname/port/vhost are all from heroku config. If I change the username or password, the error changes to ProbableAuthenticationError which makes me believe the authentication is at least correct, but likely an issue with my vhost or some other missing configuration. I haven't seen any similar questions on SO or after an hour of Googling that didn't address my issue.

I have tried both the RABBITMQ_BIGWIG_RX_URL and RABBITMQ_BIGWIG_TX_URL environment variables for both sending and consuming, and no combination seems to work. Below is the code I have for attempting to connect.

url = 'small-laurel-24.bigwig.lshift.net'
port = 10019
vhost = '/notmyrealvhost'

credentials = pika.PlainCredentials('username', 'password')
parameters = pika.ConnectionParameters(url, port, vhost, credentials=credentials)
connection = pika.BlockingConnection(parameters)

Is there something I'm missing or any way to figure out what specifically is configured wrong? I'm at a loss here. Much thanks in advance!

I am running pika 0.9.14, python 2.7.3.

like image 491
Stephen Avatar asked Sep 02 '14 09:09

Stephen


1 Answers

The problem was most likely that you added the forward slash character in your virtual-host. Many users confuse this with the forward slash being the root directory, but it is actually just the default virtual-host name.

Unless you actually named the virtual-host using a forward slash, the name will always be identical to the name you see in the management console, e.g:

  • my_virtualhost and not /my_virtualhost

This is why your solution worked as you did not add the extra forward slash when using URLParameters.

Your original code would have looked like this using URLParameters:

amqp://username:[email protected]:10018/%2Fnotmyrealvhost

While the working version you mentioned in your answer above does not have the forward slash (%2F) character.

amqp://username:[email protected]:10018/notmyrealvhost
like image 75
eandersson Avatar answered Oct 26 '22 22:10

eandersson