【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不同方向入手,别的软件也有类似的情况。

相关推荐
Thomas.Sir2 天前
第21课:PyTorch|GPU多卡训练与分布式训练基础【让多卡并行成为你的加速引擎】
人工智能·pytorch·分布式
Cicada1282 天前
库存消息消费的正确性设计——从幂等窗口到批量流水线
分布式·系统架构
Nano叶落2 天前
Kafka 消费积压排查入门:Docker 搭环境亲手制造一次 ‘消息堵死‘,10 分钟看懂 Lag
kafka
Francek Chen3 天前
【大数据处理与分析】数据仓库Hive:04 数据仓库Hive概述
大数据·数据仓库·hive·hadoop·分布式
Gl�ria3 天前
Hadoop/YARN 集群缩容:下线DN节点
大数据·hadoop·分布式
吉甫作诵3 天前
Kafka 集群安装与运维实战:消费组排查、Offset 重置与副本重分配
大数据·运维·分布式·kafka·消息队列
imDwAaY3 天前
消息队列四大核心问题:顺序性、幂等性、可靠性与一致性
学习·kafka·rabbitmq
wno7044 天前
Spring Boot整合Kafka
spring boot·kafka
是Dream呀4 天前
Harness 工程:让 Agent 真正把任务做完
人工智能·分布式·缓存·agent