client side py
import pika, sys, os,ssl
def main():
context =ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.verify_mode = ssl.CERT_REQUIRED
context.load_verify_locations("/home/dev/Desktop/files_from_ssh/ca_certificate.pem")
credentials = pika.PlainCredentials(username='xxx', password='xxxx')
conn_params = pika.ConnectionParameters(host="***",port=5672,heartbeat=60,ssl_options=pika.SSLOptions(context),
virtual_host="test_environment",credentials=credentials)
connection = pika.BlockingConnection(conn_params)
channel = connection.channel()
channel.queue_declare(queue='ssl_test')
def callback(ch, method, properties, body):
print(" [x] Received %r" % body)
channel.basic_consume(queue='ssl_test', on_message_callback=callback, auto_ack=True)
print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print("Interrupted")
try:
sys.exit(0)
except SystemExit:
pass
在服务器端启用TLS
x一个一个一个一个x一个一个二个x
从该站点引用:https://pika.readthedocs.io/en/stable/examples/tls_server_authentication.html无法连接到服务器,有人能帮我一把吗有点新的rabbitmq这是错误我得到ConnectionResetError:[Errno 104]连接被对等方重置
1条答案
按热度按时间qzwqbdag1#
我在这里回答了这个问题:
https://github.com/rabbitmq/rabbitmq-server/discussions/6776
rabbitmq-users
邮件列表,仅在StackOverflow上偶尔回答问题。