Error sending fetch request (sessionId=INVALID, epoch=INITIAL) to node 0

1 背景

使用 kafka Java Client消费 kafka中的消息,但是消费不到消息,而且日志中打印如下信息

Error sending fetch request (sessionId=INVALID, epoch=INITIAL) to node 0: {}.

2 问题解决

解决问题的前提是 kafka集群的运行状态是正常的,而且kafka和消费者之间的网络是畅通的

增加如下配置

  properties.setProperty("session.timeout.ms","600000");
  properties.setProperty("request.timeout.ms","600000");

3 解决问题思路

首先要学会查看官网,官网才是有公信力的

Apache Kafka

The expected time between heartbeats to the group coordinator when using Kafka's group management facilities. Heartbeats are used to ensure that the worker's session stays active and to facilitate rebalancing when new members join or leave the group. The value must be set lower than session.timeout.ms, but typically should be set no higher than 1/3 of that value. It can be adjusted even lower to control the expected time for normal rebalances.

Type: int
Default: 3000 (3 seconds)
Valid Values:
Importance: high

默认是45秒中会报超时,我将这个配置调整到了10分钟

Error sending fetch request (sessionId=INVALID, epoch=INITIAL) to node 0_第1张图片   默认是30秒超时,我调整为30分钟

 

你可能感兴趣的:(Kafka,kafka)