0


【Kafka】Kafka客户端认证失败:Cluster authorization failed.

背景

  1. kafka客户端是公司内部基于spring-kafka封装的
  2. spring-boot版本:3.x
  3. spring-kafka版本:2.1.11.RELEASE
  4. 集群认证方式:SASL_PLAINTEXT/SCRAM-SHA-512
  5. 经过多年的经验,以及实际验证,配置是没问题的,但是业务方反馈用相同的配置,还是报错!

错误日志

2023-12-21 18:00:44.051 [kafka-producer-network-thread | producer-1] INFO  o.a.k.c.p.i.TransactionManager - [Producer clientId=producer-1] Transiting to fatal error state due to org.apache.kafka.common.errors.ClusterAuthorizationException: Cluster authorization failed.
2023-12-21 18:00:44.066 [http-nio-8082-exec-1] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.apache.kafka.common.KafkaException: Cannot execute transactional method because we are in an error state] with root cause
org.apache.kafka.common.errors.ClusterAuthorizationException: Cluster authorization failed.
2023-12-21 18:00:44.156 [kafka-producer-network-thread | producer-1] ERROR o.a.k.c.producer.internals.Sender - [Producer clientId=producer-1] Aborting producer batches due to fatal error
org.apache.kafka.common.errors.ClusterAuthorizationException: Cluster authorization failed.
2023-12-21 18:00:44.159 [kafka-producer-network-thread | producer-1] ERROR o.s.k.s.LoggingProducerListener - Exception thrown when sending a message with key='null' and payload='测试消息' to topic test-topic:
org.apache.kafka.common.errors.ClusterAuthorizationException: Cluster authorization failed.

原因

在这里插入图片描述

封装的kafka客户端版本过低,高版本的配置项:security.protocol 的key已经换了,需要把配置项改为低版本的。
IDEA有提示,如果发现配置项不能解析或不识别,说明该配置项不正确。
具体从哪个版本开始改的,看了一遍github上的版本迭代记录,并没有提及,只能是遇到的时候多注意,有问题进行切换即可。

  • 低版本使用:spring.kafka.properties.security.protocol=SASL_PLAINTEXT
  • 高版本使用:spring.kafka.security.protocol=SASL_PLAINTEXT

问题不好排查,尤其是公司自己封装的客户端,配置项和springboot-kafka不太一样,IDEA也没有提示,可以作为一个经验吧,当配置都确认无误时,还是报错或配置不生效,尝试从因版本变更导致配置项key不同方向入手,别的软件也有类似的情况。


本文转载自: https://blog.csdn.net/sinat_14840559/article/details/135201370
版权归原作者 喝不完一杯咖啡 所有, 如有侵权,请联系我们删除。

“【Kafka】Kafka客户端认证失败:Cluster authorization failed.”的评论:

还没有评论