Kafka Admin Client giving Timeout Error for ListTopic

4.2k Views Asked by At

Hi I am trying to run this code in but it is working fine in another EC2 Azkaban instance but not giving below error for another instance.

private val adminprops = new Properties() 
adminprops.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG,"Kafka Endpoint")
private val admin = AdminClient.create(adminprops)

def topicExist(topicName: String): Boolean = {
 val result = admin.listTopics.names.get.contains(topicName)
 result
}

"Kafka Exception java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: listTopics"

2

There are 2 best solutions below

3
allen On

Network problem or setting problem.

  1. make sure "bootstrap.servers" is correct,right host and port.
  2. make sure the network is ok between the client and the broker server.

The default timeout of adminClient is 120000ms(AdminClientConfig.REQUEST_TIMEOUT_MS_CONFIG). Normally,list topics return immediately.

0
Karthik Karuppannan On

if you are using java8, that may also give these timeout errors for unknown reasons. I switched to Java17/21 and the timeout issues went away. Hope it helps some.