Kafka节点断开-这些高频重复的错误意味着什么,如何解决?

xtfmy6hx  于 11个月前  发布在  Apache
关注(0)|答案(1)|浏览(231)

我在Sping Boot 应用程序中使用了一个Kafka生产者。

@Component
public class MessageProducer {

    @Value("${topic.name}")
    private String topic;

    @Autowired
    private KafkaTemplate<Integer, String> kafkaTemplate;

    public void produceMessage(String msg) {
        kafkaTemplate.send(topic, msg);
    }
}

字符串
我在Sping Boot 配置文件application.properties中配置了以下属性:

spring.kafka.bootstrap-servers=...
topic.name=...
security.protocol=SASL_SSL
sasl.mechanism=PLAIN
spring.kafka.properties.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="..." password="...";


当我调用produceMessage时,日志会不断填充这样的消息:

2023-11-17T17:09:39.032+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Node -5 disconnected.
2023-11-17T17:09:39.032+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Cancelled in-flight API_VERSIONS request with correlation id 0 due to node -5 being disconnected (elapsed time since creation: 170ms, elapsed time since send: 170ms, request timeout: 30000ms)
2023-11-17T17:09:39.032+01:00  WARN 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Bootstrap broker broker-105.server:9093 (id: -5 rack: null) disconnected
2023-11-17T17:09:39.134+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Node -3 disconnected.
2023-11-17T17:09:39.135+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Cancelled in-flight API_VERSIONS request with correlation id 1 due to node -3 being disconnected (elapsed time since creation: 270ms, elapsed time since send: 270ms, request timeout: 30000ms)
2023-11-17T17:09:39.135+01:00  WARN 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Bootstrap broker broker-103.server:9093 (id: -3 rack: null) disconnected
2023-11-17T17:09:39.301+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Node -9 disconnected.
2023-11-17T17:09:39.301+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Cancelled in-flight API_VERSIONS request with correlation id 2 due to node -9 being disconnected (elapsed time since creation: 55ms, elapsed time since send: 55ms, request timeout: 30000ms)
2023-11-17T17:09:39.301+01:00  WARN 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Bootstrap broker broker-109.server:9093 (id: -9 rack: null) disconnected
2023-11-17T17:09:39.493+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Node -1 disconnected.
2023-11-17T17:09:39.493+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Cancelled in-flight API_VERSIONS request with correlation id 3 due to node -1 being disconnected (elapsed time since creation: 84ms, elapsed time since send: 84ms, request timeout: 30000ms)
2023-11-17T17:09:39.493+01:00  WARN 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Bootstrap broker broker-101.server:9093 (id: -1 rack: null) disconnected
2023-11-17T17:09:39.494+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Node -7 disconnected.
2023-11-17T17:09:39.494+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Cancelled in-flight API_VERSIONS request with correlation id 4 due to node -7 being disconnected (elapsed time since creation: 83ms, elapsed time since send: 83ms, request timeout: 30000ms)
2023-11-17T17:09:39.494+01:00  WARN 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Bootstrap broker broker-107.server:9093 (id: -7 rack: null) disconnected
2023-11-17T17:09:39.810+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Node -6 disconnected.
2023-11-17T17:09:39.810+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Cancelled in-flight API_VERSIONS request with correlation id 6 due to node -6 being disconnected (elapsed time since creation: 204ms, elapsed time since send: 204ms, request timeout: 30000ms)
2023-11-17T17:09:39.810+01:00  WARN 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Bootstrap broker broker-106.server:9093 (id: -6 rack: null) disconnected
2023-11-17T17:09:39.811+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Node -2 disconnected.
2023-11-17T17:09:39.811+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Cancelled in-flight API_VERSIONS request with correlation id 5 due to node -2 being disconnected (elapsed time since creation: 206ms, elapsed time since send: 206ms, request timeout: 30000ms)
2023-11-17T17:09:39.811+01:00  WARN 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Bootstrap broker broker-102.server:9093 (id: -2 rack: null) disconnected
2023-11-17T17:09:39.974+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Node -8 disconnected.
2023-11-17T17:09:39.975+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Cancelled in-flight API_VERSIONS request with correlation id 7 due to node -8 being disconnected (elapsed time since creation: 52ms, elapsed time since send: 52ms, request timeout: 30000ms)
2023-11-17T17:09:39.975+01:00  WARN 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Bootstrap broker broker-108.server:9093 (id: -8 rack: null) disconnected
2023-11-17T17:09:40.137+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Node -4 disconnected.
2023-11-17T17:09:40.137+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Cancelled in-flight API_VERSIONS request with correlation id 8 due to node -4 being disconnected (elapsed time since creation: 54ms, elapsed time since send: 54ms, request timeout: 30000ms)
2023-11-17T17:09:40.137+01:00  WARN 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Bootstrap broker broker-104.server:9093 (id: -4 rack: null) disconnected
2023-11-17T17:09:40.304+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Node -5 disconnected.
2023-11-17T17:09:40.304+01:00  INFO 35184 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Cancelled in-flight API_VERSIONS request with correlation id 9 due to node -5 being disconnected (elapsed time since creation: 58ms, elapsed time since send: 58ms, request timeout: 30000ms)

bbuxkriu

bbuxkriu1#

你需要在所有Kafka值前加上spring.kafka。参见文档。
另外,sasl.mechanism=PLAIN似乎与security.protocol=SASL_SSL相矛盾。你想要SASL_PLAINTEXT吗?
这个错误仅仅意味着引导服务器无法连接,生产者正在尝试连接到您的值broker-101-broker-109中的9个代理中的每一个。
这也可能意味着SASL配置错误(用户名/密码)。
由于您尝试使用SASL_SSL,这意味着您还需要设置spring.kafka.properties[ssl.key.password]spring.kafka.properties[ssl.keystore.location]等值。
这也可能意味着advertised.listeners在您从客户端使用的连接协议的服务器端属性上不正确。
您应该尝试使用具有相同设置的kafka-console-producer来验证连接是否工作,然后再移动到Spring客户端。
这里有一个来自Confluent的关于Confluent Cloud或本地Kafka的Sping Boot 配置的教程。
https://developer.confluent.io/get-started/spring-boot/#introduction

相关问题