I am trying to use sasl_plaintext authentication to connect to my kafka instance, i have followed the documentation provided in this repo but I can not make it work. I have successfully connected to kafka with the same authentication mechanism in dotnet and python though. here is my configuration:
conf->set("security.protocol", "SASL_PLAINTEXT", errstr);
conf->set("sasl.mechanism", "PLAIN", errstr);
conf->set("sasl.username", username, errstr);
conf->set("sasl.password", password, errstr);
here is my application log:
%7|1696836531.792|AUTH|rdkafka#producer-1| [thrd:sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap]: sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap: Auth in state APIVERSION_QUERY (handshake supported)
%7|1696836531.840|SASLMECHS|rdkafka#producer-1| [thrd:sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap]: sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap: Broker supported SASL mechanisms:
%3|1696836531.840|FAIL|rdkafka#producer-1| [thrd:sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap]: sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap: SASL PLAIN mechanism handshake failed: Broker: Request not valid in current SASL state: broker's supported mechanisms: (after 48ms in state AUTH_HANDSHAKE, 1 identical error(s) suppressed)
%3|1696836531.840|ERROR|rdkafka#producer-1| [thrd:app]: rdkafka#producer-1: sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap: SASL PLAIN mechanism handshake failed: Broker: Request not valid in current SASL state: broker's supported mechanisms: (after 48ms in state AUTH_HANDSHAKE, 1 identical error(s) suppressed)
%7|1696836532.991|AUTH|rdkafka#producer-1| [thrd:sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap]: sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap: Auth in state APIVERSION_QUERY (handshake supported)
%7|1696836533.029|SASLMECHS|rdkafka#producer-1| [thrd:sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap]: sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap: Broker supported SASL mechanisms:
%7|1696836535.619|AUTH|rdkafka#producer-1| [thrd:sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap]: sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap: Auth in state APIVERSION_QUERY (handshake supported)
%7|1696836535.693|SASLMECHS|rdkafka#producer-1| [thrd:sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap]: sasl_plaintext://stage-app-brkr0.kafka.app:32041/bootstrap: Broker supported SASL mechanisms:
%7|1696836541.350|DESTROY|rdkafka#producer-1| [thrd:app]: Terminating instance (destroy flags none (0x0))
%4|1696836541.350|TERMINATE|rdkafka#producer-1| [thrd:app]: Producer terminating with 1 message (13 bytes) still in queue or transit: use flush() to wait for outstanding message delivery
%7|1696836541.350|DESTROY|rdkafka#producer-1| [thrd:main]: Destroy internal
%7|1696836541.350|DESTROY|rdkafka#producer-1| [thrd:main]: Removing all topics
I have also have libsasl2-dev installed but there wasn't a change in result.
I am expecting to have my application be connected to the kafka cluster successfully.
so the solution is that sasl_plaintext is disabled by default in strimzi kafka cluster and we had to use another method.