Open moh-incom opened 21 hours ago
I was able to hack reauthentication together by accessing the consumer's internal AIOKafkaConnections
and running _do_sasl_handshake()
periodically combined with some rather tricky commit locking, heartbeat stopping/starting and an additional lock to ensure that the client does not fetch more records while the handshake is ongoing. If any requests are made during the handshake, the broker will terminate the connection.
Describe the bug When a consumer's connection outlives its SASL authentication (in this case an OAuth token), then consumer will fail to fetch new records because the broker no longer accepts any requests other than
SaslHandshakeRequest
andSaslAuthenticateRequest
. See KIP-368 for more details.As an example, if tokens have a valid duration of 5 minutes, the consumer will run fine for 5 minutes after which it will begin failing when it sends new requests. For example, this
HeartbeatRequest
for the group coordinator fails because the channel's session is expired:I suspect this is also an issue for admin and producer clients.
Expected behaviour I expect the consumer to reauthenticate before its session expires.
Environment (please complete the following information):
python -c "import aiokafka; print(aiokafka.__version__)"
): 0.12.0kafka-topics.sh --version
): 3.7.0Reproducible example
The problem can be reproduced with a simple consumer such as this together with a Kafka broker configured to use secured OAuth SASL authentication for example using Strimzi. If it could be of value, I will try to create a Dockerfile to setup such a broker.