Using EXTERNAL auth in kombu
Hi. I'm quite new to rabbitMQ and i am currently trying to figure out which client library i should use for python. I really like how kombu works compared to e.g. pika, so i would prefer to use that. However, my application requires that it is possible to authenticate with the brokker using ssl certificates and the EXTERNAL authentication method. I tried connecting with kombu, but i am not quite able to get it working. Here is my code:
logging.getLogger().setLevel(logging.DEBUG)
logging.getLogger().addHandler(logging.StreamHandler())
with kombu.Connection("amqp://{}:5671/".format(os.environ["rmq_host"]), login_method='EXTERNAL', heartbeat=4, ssl = {
'ca_certs' : os.environ["rmq_ca"],
'keyfile' : os.environ["rmq_key"],
'certfile' : os.environ["rmq_cert"],
'cert_reqs': ssl.CERT_REQUIRED,
}) as connection:
connection.connect()
I get the following exception when trying to connect:
Start from server, version: 0.9, properties: {'capabilities': {'publisher_confirms': True, 'exchange_exchange_bindings': True, 'basic.nack': True, 'consumer_cancel_notify': True, 'connection.blocked': True, 'consumer_priorities': True, 'authentication_failure_close': True, 'per_consumer_qos': True, 'direct_reply_to': True}, 'cluster_name': 'rabbit@Leviathan', 'copyright': 'Copyright (C) 2007-2017 Pivotal Software, Inc.', 'information': 'Licensed under the MPL. See http://www.rabbitmq.com/', 'platform': 'Erlang/OTP 20.0.1', 'product': 'RabbitMQ', 'version': '3.6.12'}, mechanisms: [b'EXTERNAL'], locales: ['en_US']
Traceback (most recent call last):
File "main.py", line 30, in <module>
__main__()
File "main.py", line 21, in __main__
connection.connect()
File "/home/stefan/RMUASD_venv/lib/python3.6/site-packages/kombu/connection.py", line 261, in connect
return self.connection
File "/home/stefan/RMUASD_venv/lib/python3.6/site-packages/kombu/connection.py", line 802, in connection
self._connection = self._establish_connection()
File "/home/stefan/RMUASD_venv/lib/python3.6/site-packages/kombu/connection.py", line 757, in _establish_connection
conn = self.transport.establish_connection()
File "/home/stefan/RMUASD_venv/lib/python3.6/site-packages/kombu/transport/pyamqp.py", line 130, in establish_connection
conn.connect()
File "/home/stefan/RMUASD_venv/lib/python3.6/site-packages/amqp/connection.py", line 288, in connect
self.drain_events(timeout=self.connect_timeout)
File "/home/stefan/RMUASD_venv/lib/python3.6/site-packages/amqp/connection.py", line 471, in drain_events
while not self.blocking_read(timeout):
File "/home/stefan/RMUASD_venv/lib/python3.6/site-packages/amqp/connection.py", line 477, in blocking_read
return self.on_inbound_frame(frame)
File "/home/stefan/RMUASD_venv/lib/python3.6/site-packages/amqp/method_framing.py", line 55, in on_frame
callback(channel, method_sig, buf, None)
File "/home/stefan/RMUASD_venv/lib/python3.6/site-packages/amqp/connection.py", line 481, in on_inbound_method
method_sig, payload, content,
File "/home/stefan/RMUASD_venv/lib/python3.6/site-packages/amqp/abstract_channel.py", line 128, in dispatch_method
listener(*args)
File "/home/stefan/RMUASD_venv/lib/python3.6/site-packages/amqp/connection.py", line 368, in _on_start
b", ".join(self.mechanisms).decode()))
amqp.exceptions.ConnectionError: Couldn't find appropriate auth mechanism (can offer: AMQPLAIN, PLAIN; available: EXTERNAL)
It seems that external auth is not supported by kombu (or maybe actually pyamqp). Is this correct, or am i just using it wrong?
External authentication is provided as a RabbitMQ plugin. Kombu does support external authentication as far as I can recall.