Skip to content

How to check for SASL Authentication Errors? #1398

Open
@mkmoisen

Description

@mkmoisen

Description

from confluent_kafka import Consumer

conf = {
    'bootstrap.servers': 'localhost:8082',
    'group.id': 'myconsumer',
    'security.protocol': 'sasl_ssl',
    'sasl.mechanism': 'PLAIN',
    'sasl.username': 'myusername',
    'sasl.password': 'badpassword'
}

consumer = Consumer(conf)

Invoking the code above with an incorrect password does not raise any error. It seems like it asynchronously attempts to authorize, and after a few seconds a separate thread will print the following to the screen:

%3|1658355875.069|FAIL|rdkafka#consumer-1| [thrd:sasl_ssl://localhost:9092/boots]: sasl_ssl://localhost:9092/bootstrap: SASL authentication error: Authentication failed (after 5170ms in state AUTH_REQ, 5 identical error(s) suppressed)

If I then subscribe to a topic and poll, on_assign is never called and the message is never polled.

How do I figure out if I've been correctly authorized?

Would it perhaps be better if it raised a synchronous exception?

Checklist

Please provide the following information:

  • confluent-kafka-python and librdkafka version (confluent_kafka.version() and confluent_kafka.libversion()):

    1.8.2 and 1.8.2

Metadata

Metadata

Assignees

Labels

enhancementRequesting a feature changepriority:lowMaintainer triage tag for indicating low impact or criticality issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions