gmr / rabbitpy

A pure python, thread-safe, minimalistic and pythonic RabbitMQ client library
http://rabbitpy.readthedocs.org
BSD 3-Clause "New" or "Revised" License
242 stars 58 forks source link

Incorrect exception raised when accessing unknown vhost #95

Closed yuha0 closed 7 years ago

yuha0 commented 8 years ago

When I was making a new connection to broker with an unknown vhost, rabbitpy.exceptions.AMQPNotAllowed was raised instead of rabbitpy.exceptions.AMQPInvalidPath.

My broker version is 'RabbitMQ 3.6.1'.

gmr commented 8 years ago

If you can provide a trace of the conversation with either DEBUG logs from rabbitpy or with tcpdump, I can verify that is the case. My guess is that RabbitMQ didn't allow your user to connect to the VHost and it returned AMQPNotAllowed.

yuha0 commented 8 years ago

You are right. The DEBUG message says access refused. The root cause was that the vhost "testtttt" did not exist. Here's the log:

DEBUG:rabbitpy.base:Connection setting state to 'Opening'
DEBUG:rabbitpy.base:IO setting state to 'Opening'
DEBUG:rabbitpy.events:Waiting for 1 seconds on event: Socket Connected
DEBUG:rabbitpy.io:Connecting to ('10.211.55.6', 5672)
DEBUG:rabbitpy.base:IO setting state to 'Open'
DEBUG:rabbitpy.io:Socket connected
DEBUG:rabbitpy.io:Returning PollPoller
DEBUG:rabbitpy.connection:Adding channel 0 to io
DEBUG:rabbitpy.base:Channel0 setting state to 'Opening'
DEBUG:rabbitpy.base:Writing frame: ProtocolHeader
DEBUG:rabbitpy.channel0:Received frame: 'Connection.Start'
DEBUG:rabbitpy.channel0:Server information: 'Licensed under the MPL.  See http://www.rabbitmq.com/'
DEBUG:rabbitpy.channel0:Server product: 'RabbitMQ'
DEBUG:rabbitpy.channel0:Server copyright: 'Copyright (C) 2007-2016 Pivotal Software, Inc.'
DEBUG:rabbitpy.channel0:Server supports exchange_exchange_bindings: True
DEBUG:rabbitpy.channel0:Server supports connection.blocked: True
DEBUG:rabbitpy.channel0:Server supports authentication_failure_close: True
DEBUG:rabbitpy.channel0:Server supports direct_reply_to: True
DEBUG:rabbitpy.channel0:Server supports basic.nack: True
DEBUG:rabbitpy.channel0:Server supports per_consumer_qos: True
DEBUG:rabbitpy.channel0:Server supports consumer_priorities: True
DEBUG:rabbitpy.channel0:Server supports consumer_cancel_notify: True
DEBUG:rabbitpy.channel0:Server supports publisher_confirms: True
DEBUG:rabbitpy.channel0:Server cluster_name: 'rabbit@ubuntu1404'
DEBUG:rabbitpy.channel0:Server platform: 'Erlang/OTP'
DEBUG:rabbitpy.channel0:Server version: '3.6.1'
DEBUG:rabbitpy.base:Writing frame: Connection.StartOk
DEBUG:rabbitpy.channel0:Received frame: 'Connection.Tune'
DEBUG:rabbitpy.channel0:Tuning, client: 300
DEBUG:rabbitpy.channel0:Started a heartbeat timer that will fire in 90 sec
DEBUG:rabbitpy.base:Writing frame: Connection.TuneOk
DEBUG:rabbitpy.base:Writing frame: Connection.Open
DEBUG:rabbitpy.channel0:Received frame: 'Connection.Close'
WARNING:rabbitpy.channel0:RabbitMQ closed the connection (530): NOT_ALLOWED - access to vhost 'testtttt' refused for user 'admin'
DEBUG:rabbitpy.base:Channel0 setting state to 'Closed'
DEBUG:rabbitpy.io:Exiting due to closed socket
DEBUG:rabbitpy.io:Exiting IOLoop.run
DEBUG:rabbitpy.io:Exiting IO.run
DEBUG:rabbitpy.base:IO setting state to 'Closing'
DEBUG:rabbitpy.base:IO setting state to 'Closed'
Error: NOT_ALLOWED - access to vhost 'testtttt' refused for user 'admin'

According to the documentation, I was expecting rabbitpy.exceptions.AMQPInvalidPath because there's no vhost called "testtttt".

gmr commented 7 years ago

That error is what's coming back from RabbitMQ -- I'd send an email to the mailing list to see what they have to say on this issue.