Pika Amqps Connection: Connection attempt completed with AMQ



我试图使用pika连接到AMQPS-Service(我没有配置访问或获得证书的方法)。

代码如下:

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

每次我尝试执行这个,它失败了:

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)')",)',)

不幸的是,我不知道服务器返回的是哪个协议。

使用qpid-protonsasl_enabled: True选项集,它工作没有任何问题。

from proton import Message
from proton.utils import BlockingConnection
conn = BlockingConnection(
url,
password=password,
user=username,
sasl_enabled=True,
)

然而,我还没有找到一种方法来做到这一点与pika

从阅读问题和后来的评论中我猜测远程端点支持AMQP 1.0,而Pika客户端似乎只支持0.9.1草案AMQP规范,这将使返回的错误变得合理。您需要使用能够使用ISO规范AMQP 1.0标准的客户机

最新更新