I have configured the Kafka with SASL/OAUTHBEARER but, consumers and producers when hitting the Kafka on port 9093 the Broker is validating the client correctly but, the client is continuously trying to make connection with the broker and finally not exchanging the messages. Getting the warning below and finally client is not able to produce or consume messages. I have tried with both Java and NodeJS none working.
13:46:13,731 INFO org.apache.kafka.clients.NetworkClient - [Consumer clientId=admin, groupId=bp1-cg] Cancelled in-flight API_VERSIONS request with correlation id 30 due to node -1 being disconnected (elapsed time since creation: 171ms, elapsed time since send: 171ms, request timeout: 30000ms)
13:46:13,731 WARN org.apache.kafka.clients.NetworkClient - [Consumer clientId=admin, groupId=bp1-cg] Bootstrap broker 158.177.250.15:9093 (id: -1 rack: null) disconnected
I faced a similar issue. In my case, this is caused by a connection session lifetime set to 0ms after the SASL client state is
COMPLETED
. Since this is set to 0ms, the client will get disconnected immediately.I will suggest to check your log by enabling this logger in your log4j.properties:
In my case, I saw this debug log stating a weird expiration time that I found useful to understand what the issue was:
I'm using
SASL_SSL
withOAUTHBEARER
mechanism with customAuthenticateCallbackHandler
andOAuthBearerToken
. In my implementation, I mistakenly set the value returned bylifetimeMs()
andstartTimeMs()
functions in seconds unit, where it is supposed to be in milliseconds unit.exp
andiat
from jwt claims are in second so I need to multiply it by 1000 before returning it from the function to fix this issue.Hope it helps!