I am trying to use pika
connect to a AMQPS-Service (to which I have no config access or a way to get the certificates).
Here's the code:
import pika
from urllib.parse import urlparse
import ssl
credentials = pika.PlainCredentials(username, password)
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.verify_mode = ssl.CERT_NONE
ssl_options=pika.SSLOptions(context)
params = pika.ConnectionParameters(
host=url.hostname,
port=url.port,
credentials=credentials,
ssl_options=ssl_options
)
connection = pika.BlockingConnection(params)
channel = connection.channel() # start a channel
Everytime I try to execute this though, it fails with:
ERROR:pika.adapters.utils.connection_workflow:AMQPConnector - reporting failure:
AMQPConnectorAMQPHandshakeError:
IncompatibleProtocolError: The protocol returned by the server is not supported:
('StreamLostError:
("Stream connection lost: SSLEOFError(8, \'EOF occurred in violation of protocol (_ssl.c:2633)\')",)',)
Unfortunately, I do not know which protocol is returned by the server.
Using qpid-proton
with the sasl_enabled: True
option set, it works without any issues.
from proton import Message
from proton.utils import BlockingConnection
conn = BlockingConnection(
url,
password=password,
user=username,
sasl_enabled=True,
)
However, I haven't found a way to do this with pika
.
CodePudding user response:
My guess from reading the question and later comments the remote endpoint supports AMQP 1.0 and the Pika client appears to support only the 0.9.1 draft AMQP spec which would make the returned error sensible. You'd need to use a client capable of using the ISO spec AMQP 1.0 standard