'Kafka Admin Client giving Timeout Error for ListTopic

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"



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1