SASL PLAIN 机制握手失败

问题描述 投票:0回答:0

`

from confluent_kafka import Producer


def delivery_report(err, msg):
    if err is not None:
        print('Message delivery failed: {}'.format(err))
    else:
        print('Message delivered to {} [{}]'.format(msg.topic(), msg.partition()))


conf = {
    'bootstrap.servers': 'localhost:9092',
    'security.protocol': 'SASL_PLAINTEXT',
    'sasl.mechanisms': 'PLAIN',
    'sasl.username': 'admin',
    'sasl.password': 'admin-secret'
}

producer = Producer(conf)

topic = 'test'
message = 'Hello, Kafka!'
producer.produce(topic, key=None, value=message, callback=delivery_report)

producer.flush()

解决这个错误 SASL PLAIN 机制握手失败

我能够通过终端创建主题生产和消费消息

apache-kafka spring-kafka confluent-platform
© www.soinside.com 2019 - 2024. All rights reserved.