-
Notifications
You must be signed in to change notification settings - Fork 934
Description
The confluent-kafka-python Producer, when using an OAuth token and remaining idle for a period exceeding the token's lifetime, logs transient WARNING and ERROR messages, these messages unnecessarily clutter logs.
This behavior is observed with a producer configured for OAuth authentication (sasl.mechanism=OAUTHBEARER and oauth_cb). The logs occur when an existing, idle broker connection is closed by the broker after the token expires.
ssl://kafka.io:9092/bootstrap: Disconnected (after 43ms in state UP, 1 identical error(s) suppressed)
%6|1757756181.356|FAIL|rdkafka#producer-2| [thrd:sasl_ssl://kafka.io:9093/0]: sasl_ssl://kafka.io:9093/0: Disconnected (after 49ms in state UP, 1 identical error(s) suppressed)
%3|1757756212.977|FAIL|rdkafka#producer-2| [thrd:sasl_ssl://kafka.io:9092/bootstrap]: sasl_ssl://kafka.io:9092/bootstrap: SASL authentication error: {"status":"invalid_token"} (after 150ms in state AUTH_REQ)
%3|1757756213.309|FAIL|rdkafka#producer-2| [thrd:sasl_ssl://kafka.io:9094/1]: sasl_ssl://kafka.io:9094/1: SASL authentication error: {"status":"invalid_token"} (after 160ms in state AUTH_REQ)
%4|1757756213.309|METADATA|rdkafka#producer-2| [thrd:main]: sasl_ssl://kafka.io:9094/1: Metadata request failed: partition leader query: Local: Authentication failure (0ms): Permanent
%3|1757756215.338|FAIL|rdkafka#producer-2| [thrd:sasl_ssl://kafka.io:9095/2]: sasl_ssl://kafka.io:9095/2: SASL authentication error: {"status":"invalid_token"} (after 164ms in state AUTH_REQ)
%4|1757756215.338|METADATA|rdkafka#producer-2| [thrd:main]: sasl_ssl://kafka.io:9095/2: Metadata request failed: partition leader query: Local: Authentication failure (0ms): Permanent
%3|1757756217.706|FAIL|rdkafka#producer-2| [thrd:sasl_ssl://kafka.io:9093/0]: sasl_
When a new message needs to be sent, the producer is trying to reconnect. This attempt fails with the invalid_token error, which triggers the oauth_cb to get a fresh token. The producer then successfully re-authenticates and sends the new message.
The oauth_cb is triggered by a call to poll(). Is there a way to make an idle producer's token refresh more proactive, similar to how an active consumer constantly polling avoids this issue? This could potentially prevent the initial connection failure and corresponding log messages entirely.
Can you provide few suggestions for this issue other than changing my log level / using "log.connection.close": False ??