def _connect(self, connection, reactor): assert (reactor is not None) url = self.address.next() reactor.set_connection_host(connection, url.host, str(url.port)) # if virtual-host not set, use host from address as default if self.virtual_host is None: connection.hostname = url.host log.debug("connecting to %s..." % url) transport = Transport() if self.sasl_enabled: sasl = transport.sasl() sasl.allow_insecure_mechs = self.allow_insecure_mechs if url.username: connection.user = url.username elif self.user: connection.user = self.user if url.password: connection.password = url.password elif self.password: connection.password = self.password if self.allowed_mechs: sasl.allowed_mechs(self.allowed_mechs) transport.bind(connection) if self.heartbeat: transport.idle_timeout = self.heartbeat if url.scheme == 'amqps': if not self.ssl_domain: raise SSLUnavailable("amqps: SSL libraries not found") self.ssl = SSL(transport, self.ssl_domain) self.ssl.peer_hostname = self.ssl_sni or self.virtual_host or url.host if self.max_frame_size: transport.max_frame_size = self.max_frame_size
def _connect(self, connection, reactor): assert (reactor is not None) url = self.address.next() reactor.set_connection_host(connection, url.host, str(url.port)) # if virtual-host not set, use host from address as default if self.virtual_host is None: connection.hostname = url.host log.debug("connecting to %r..." % url) transport = Transport() if self.sasl_enabled: sasl = transport.sasl() sasl.allow_insecure_mechs = self.allow_insecure_mechs if url.username: connection.user = url.username elif self.user: connection.user = self.user if url.password: connection.password = url.password elif self.password: connection.password = self.password if self.allowed_mechs: sasl.allowed_mechs(self.allowed_mechs) transport.bind(connection) if self.heartbeat: transport.idle_timeout = self.heartbeat if url.scheme == 'amqps': if not self.ssl_domain: raise SSLUnavailable("amqps: SSL libraries not found") self.ssl = SSL(transport, self.ssl_domain) self.ssl.peer_hostname = self.ssl_sni or self.virtual_host or url.host if self.max_frame_size: transport.max_frame_size = self.max_frame_size