How can Python detect that my RabbitMQ password failed?
I am trying to write a Python application that uses RabbitMQ by means of the [Pika library](http://pypi.python.org/pypi/pika). I am using the latest version, 0.9.5. My problem is that my Python code cannot detect when its RabbitMQ username and password are incorrect, because I cannot figure out how to register a Pika callback that would inform me of the error. My code is making the connection like this:

    import pika

    class MyClient(object):
        def __init__(self, host, username, password):
            self.host = host
            self.username = username
            self.password = password
            self.connection = None

        def connect(self):
            credentials = pika.PlainCredentials(self.username, self.password)
            parameters = pika.ConnectionParameters(
                host=self.host, credentials=credentials, heartbeat=True,
                )
            self.connection = pika.SelectConnection(
                parameters, self.on_connected,
                )
            self.connection.add_on_close_callback(self.on_close)
            self.connection.ioloop.start()

        def on_connected(self, *args, **kw):
            print 'I am connected!', args, kw

        def on_close(self, *args, **kw):
            print 'I am closed!', args, kw

    my_client = MyClient('...', '...', '...')
    my_client.connect()

    # (Good, I remembered to remove the username and password
    #  before pasting to Stack Overflow!)

If I run this script, then the `ioloop` runs for a bit above three seconds and then the program terminates. I cannot figure out how to register a callback, or even to simply inspect the state of the dead connection, to determine that an error occurred or to find out specifically that it is a bad password error. Have I missed something crucial in the Pika documentation?

Could someone help me understand how Pika 0.9.5 error handling is supposed to work? Or is 0.9.5 some sort of terrible experiment that I should be avoiding by using an earlier version of Pika instead, now that I have noticed [this email message](http://groups.google.com/group/rabbitmq-discuss/browse_thread/thread/405983daa276ea4b?fwc=1) that seems to indicate that this new line of development has become a dead end?

Thanks for any help!
How can Python detect that my RabbitMQ password failed?
===

I am trying to write a Python application that uses RabbitMQ by means of the [Pika library](http://pypi.python.org/pypi/pika). I am using the latest version, 0.9.5. My problem is that my Python code cannot detect when its RabbitMQ username and password are incorrect, because I cannot figure out how to register a Pika callback that would inform me of the error. My code is making the connection like this:

    import pika

    class MyClient(object):
        def __init__(self, host, username, password):
            self.host = host
            self.username = username
            self.password = password
            self.connection = None

        def connect(self):
            credentials = pika.PlainCredentials(self.username, self.password)
            parameters = pika.ConnectionParameters(
                host=self.host, credentials=credentials, heartbeat=True,
                )
            self.connection = pika.SelectConnection(
                parameters, self.on_connected,
                )
            self.connection.add_on_close_callback(self.on_close)
            self.connection.ioloop.start()

        def on_connected(self, *args, **kw):
            print 'I am connected!', args, kw

        def on_close(self, *args, **kw):
            print 'I am closed!', args, kw

    my_client = MyClient('...', '...', '...')
    my_client.connect()

    # (Good, I remembered to remove the username and password
    #  before pasting to Stack Overflow!)

If I run this script, then the `ioloop` runs for a bit above three seconds and then the program terminates. I cannot figure out how to register a callback, or even to simply inspect the state of the dead connection, to determine that an error occurred or to find out specifically that it is a bad password error. Have I missed something crucial in the Pika documentation?

Could someone help me understand how Pika 0.9.5 error handling is supposed to work? Or is 0.9.5 some sort of terrible experiment that I should be avoiding by using an earlier version of Pika instead, now that I have noticed [this email message](http://groups.google.com/group/rabbitmq-discuss/browse_thread/thread/405983daa276ea4b?fwc=1) that seems to indicate that this new line of development has become a dead end?

Thanks for any help!