Kafka connection abnormal org.apache.kafka . common.errors.TimeoutException : Failed to update metadata after 60000 ms.

Introduction: there are many problems about hosts on the Internet. After testing, I found out that it is not. After testing by myself, I introduced three solutions to most problems:

1. Firewall port not opened or closed

firewall generally local test will be closed, the line is generally open, it is recommended to add port

add port:

# --permanent 为永久添加,不指定此参数重启后失效
firewall-cmd --zone=public --add-port=9092/tcp --permanent

delete port:

firewall-cmd --zone=public --remove-port=80/tcp --permanent

view all ports:

 firewall-cmd --zone=public --list-ports

view specified port:

firewall-cmd --zone= public --query-port=9092/tcp

view port status:

netstat -tunlp

overload:

firewall-cmd --reload

firewall command:

#开启防火墙 
service firewalld start
#启用防火墙 
service firewalld enable (永久生效)
#关闭防火墙 
service firewalld stop (重启后失效)
#禁用防火墙 
service firewalld disable (永久生效)
#重启防火墙 
service firewalld restart
#查看状态 
service firewalld status

2. Kafka service entry address not specified

edit the server.properties in the config directory of kafka, and add the address of the service entry to the external service:

注意:此ip为kafka所在主机的ip地址
listeners=PLAINTEXT://192.168.5.228:9092

3. The kafka version in the project is inconsistent with the kafka version installed on the server

modify maven pom. XML file, specify the corresponding kafka coordinates,
I installed kafka_2.12-2.1.0, the corresponding coordinates are:

<dependency>
      <groupId>org.apache.kafka</groupId>
      <artifactId>kafka_2.11</artifactId>
      <version>0.10.0.0</version>
</dependency>

Read More: