Open han1448 opened 2 years ago
@han1448 thanks for reporting the issue, we will check it out and get back to you
@han1448 please share the steps to start your application and send message to get the reported error
@mcraj017
https://github.com/han1448/kafka-sasl-native
Here is my test repo and I wrote README.md.
However, for actual testing, you need a broker with kafka topics and sasl authentication settings for testing.
It seems that the username of ScramLoginModule cannot be obtained from the kafka sasl configuration rather than the issue of sending and receiving messages.
Hi @han1448. I will try first to reproduce the issue locally. If you have a Dockerfile for launching kafka that meets the config of your app, it would be great. Any other questions or updates, I will let you know.
Hi. @rodrigar-mx I've updated my repo and added kafka docker. In this case I did not configure ssl, only sasl authentication was added. The error log is a little different from before, but not sure if the error is caused by the same authentication issue.
This scenario also works fine without native image.
$ git clone https://github.com/han1448/kafka-docker.git
$ git checkout seunghyeon/add-jaas
$ docker-compose -f docker-compose-single-broker.yml up
Required to install kafka client in local
$ ./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic testtopic1
Created topic testtopic1.
$ git clone https://github.com/han1448/kafka-sasl-native
$ git checkout seunghyeon/test
$ ./mvnw -Pnative -DskipTests clean package
target/kafka-sasl
2022-01-12 15:20:24.434 INFO 8942 --- [ad | producer-1] o.a.k.common.network.SaslChannelBuilder : [Producer clientId=producer-1] Failed to create channel due to
org.apache.kafka.common.errors.SaslAuthenticationException: Failed to configure SaslClientAuthenticator
Caused by: org.apache.kafka.common.errors.SaslAuthenticationException: Failed to create SaslClient with mechanism PLAIN
2022-01-12 15:20:24.435 WARN 8942 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient : [Producer clientId=producer-1] Error connecting to node localhost:9092 (id: -1 rack: null)
java.io.IOException: Channel could not be created for socket java.nio.channels.SocketChannel[closed]
at org.apache.kafka.common.network.Selector.buildAndAttachKafkaChannel(Selector.java:348) ~[na:na]
at org.apache.kafka.common.network.Selector.registerChannel(Selector.java:329) ~[na:na]
at org.apache.kafka.common.network.Selector.connect(Selector.java:256) ~[na:na]
at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:1006) ~[na:na]
at org.apache.kafka.clients.NetworkClient.access$600(NetworkClient.java:75) ~[na:na]
at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:1177) ~[na:na]
at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:1065) ~[na:na]
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:561) ~[na:na]
at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:325) ~[na:na]
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:240) ~[na:na]
at java.lang.Thread.run(Thread.java:829) ~[na:na]
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:596) ~[na:na]
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192) ~[na:na]
Caused by: org.apache.kafka.common.KafkaException: org.apache.kafka.common.errors.SaslAuthenticationException: Failed to configure SaslClientAuthenticator
at org.apache.kafka.common.network.SaslChannelBuilder.buildChannel(SaslChannelBuilder.java:228) ~[na:na]
at org.apache.kafka.common.network.Selector.buildAndAttachKafkaChannel(Selector.java:338) ~[na:na]
... 12 common frames omitted
This log is a log that does not use native image and works fine.
2022-01-12 15:25:52.570 INFO 12635 --- [ main] o.a.k.c.s.authenticator.AbstractLogin : Successfully logged in.
2022-01-12 15:25:52.598 INFO 12635 --- [ main] o.a.kafka.common.utils.AppInfoParser : Kafka version: 2.7.1
2022-01-12 15:25:52.599 INFO 12635 --- [ main] o.a.kafka.common.utils.AppInfoParser : Kafka commitId: 61dbce85d0d41457
2022-01-12 15:25:52.599 INFO 12635 --- [ main] o.a.kafka.common.utils.AppInfoParser : Kafka startTimeMs: 1641968752597
2022-01-12 15:25:52.906 INFO 12635 --- [ad | producer-1] org.apache.kafka.clients.Metadata : [Producer clientId=producer-1] Cluster ID: LCUnyePpSUKkAupT3uCuOw
success
2022-01-12 15:25:53.058 INFO 12635 --- [ main] c.e.kafkasasl.KafkaSaslApplicationKt : Started KafkaSaslApplicationKt in 1.771 seconds (JVM running for 2.412)
2022-01-12 15:25:53.064 INFO 12635 --- [ionShutdownHook] o.a.k.clients.producer.KafkaProducer : [Producer clientId=producer-1] Closing the Kafka producer with timeoutMillis = 30000 ms.
2022-01-12 15:25:53.071 INFO 12635 --- [ionShutdownHook] org.apache.kafka.common.metrics.Metrics : Metrics scheduler closed
2022-01-12 15:25:53.071 INFO 12635 --- [ionShutdownHook] org.apache.kafka.common.metrics.Metrics : Closing reporter org.apache.kafka.common.metrics.JmxReporter
2022-01-12 15:25:53.072 INFO 12635 --- [ionShutdownHook] org.apache.kafka.common.metrics.Metrics : Metrics reporters closed
2022-01-12 15:25:53.072 INFO 12635 --- [ionShutdownHook] o.a.kafka.common.utils.AppInfoParser : App info kafka.producer for producer-1 unregistered
Process finished with exit code 0
And also without sasl, native-image producer works find too. Thank you in advance.
Hi there,
Also having an issue with Kafka SASL authentication, however having a different error output from @han1448's and was about to open an issue when stumbled into this one. Similar use case for spring native
, but with java 17
(should not be that different under the hood) and I'm using a newer version of Spring Boot (2.6.2 vs 2.5.6).
https://github.com/a-inacio/spring-native-kafka/
I believe it is related to this issue, so I'm commenting and leaving my own repo here.
Can be tried by running docker compose up
, provided you have your settings first on a local.env
file (details in the readme). Thanks to @han1448 for already providing the hints to setup a simple broker with SASL, have the same requirements. My docker file omits a runtime layer (since I was not sure if I could be missing out something from the compilation step, nevertheless, no differences here).
Also took some time to experiment with the extra Native Hints I found on Han's repo but had no effect on my error message.
Additionally, checked this topic for Quarkus where it seems to be a connection and even references Graal, might be worth having a look at this @rodrigar-mx: https://github.com/quarkusio/quarkus/issues/8168
Maybe @rodrigar-mx you can use the same credentials and try both our applications at the same time or use my docker file to dockerize quickly @han1448's one (I'm sure I'll benefit from your effort either way).
Sorry if I'm getting out of topic and thank you all in advance!
Thank you for your comment @a-inacio. It looks the same issue in my comment above.
@rodrigar-mx.
It shows different error using security protocol SASL_PLAINTEXT
and SASL_SSL
The first NullPointerException is when SASL_SSL
is used, and the situation tested in the comment above is when SASL_PLAINTEXT
is used.
SASL_SSL
SASL_PLAINTEXT
Can reproduce error in the comment above repo in local as same as @a-inacio commented.
Describe the issue I got
NullPointerException
error when trying to authenticate with kafka sasl. I already reported an issue to spring native a few months ago, but I'm curious about the current situation. I tried again with the latest version but got the same error. This app works fine without native image.Steps to reproduce the issue
Note
: Need to change topic, kafka broker, sasl information.Describe GraalVM and your environment:
More details build logs
Build success but when i send a message, I got error.