'Establish connection to the AMQP broker.'

def establish_connection(self):

    conninfo = self.client
    for (name, default_value) in items(self.default_connection_params):
        if (not getattr(conninfo, name, None)):
            setattr(conninfo, name, default_value)
    if conninfo.ssl:
        raise NotImplementedError(NO_SSL_ERROR)
    opts = dict({u'host': conninfo.host, u'userid': conninfo.userid, u'password': conninfo.password, u'virtual_host': conninfo.virtual_host, u'login_method': conninfo.login_method, u'insist': conninfo.insist, u'ssl': conninfo.ssl, u'connect_timeout': conninfo.connect_timeout}, **(conninfo.transport_options or {}))
    conn = self.Connection(**opts)
    conn.client = self.client
    self.client.drain_events = conn.drain_events
    return conn
