Apache beam: Timeout while initializing partition 'topic-1'. Kafka client may not be able to connect to servers

3/8/2019

I got this error when my Apache beam application connects to my Kafka cluster with ACL enabled. Please help me fix this issue.

Caused by: java.io.IOException: Reader-4: Timeout while initializing partition 'test-1'. Kafka client may not be able to connect to servers.
    org.apache.beam.sdk.io.kafka.KafkaUnboundedReader.start(KafkaUnboundedReader.java:128)
    org.apache.beam.runners.dataflow.worker.WorkerCustomSources$UnboundedReaderIterator.start(WorkerCustomSources.java:779)
    org.apache.beam.runners.dataflow.worker.util.common.worker.ReadOperation$SynchronizedReaderIterator.start(ReadOperation.java:361)
    org.apache.beam.runners.dataflow.worker.util.common.worker.ReadOperation.runReadLoop(ReadOperation.java:194)
    org.apache.beam.runners.dataflow.worker.util.common.worker.ReadOperation.start(ReadOperation.java:159)
    org.apache.beam.runners.dataflow.worker.util.common.worker.MapTaskExecutor.execute(MapTaskExecutor.java:76)
    org.apache.beam.runners.dataflow.worker.StreamingDataflowWorker.process(StreamingDataflowWorker.java:1228)
    org.apache.beam.runners.dataflow.worker.StreamingDataflowWorker.access$1000(StreamingDataflowWorker.java:143)
    org.apache.beam.runners.dataflow.worker.StreamingDataflowWorker$6.run(StreamingDataflowWorker.java:967)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    java.lang.Thread.run(Thread.java:745)

I have a Kafka cluster with 3 nodes on GKE. I created a topic with replication-factor 3 and partition 5.

kafka-topics --create --zookeeper zookeeper:2181 \
  --replication-factor 3 --partitions 5 --topic topic

I set read permission on a topic test for test_consumer_group consumer group.

kafka-acls --authorizer-properties zookeeper.connect=zookeeper:2181 \
  --add --allow-principal User:CN=myuser.test.io --consumer \
  --topic test --group 'test_consumer_group'

In my Apache beam application, I set configuration group.id=test_consumer_group.

Also testing with console consumer and it is not working as well.

$ docker run --rm   -v `pwd`:/cert   confluentinc/cp-kafka:5.1.0 \
  kafka-console-consumer   --bootstrap-server kafka.xx.xx:19092 \
  --topic topic --consumer.config /cert/client-ssl.properties
[2019-03-08 05:43:07,246] WARN [Consumer clientId=consumer-1, groupId=test_consumer_group]
Received unknown topic or partition error in ListOffset request for
partition test-3 (org.apache.kafka.clients.consumer.internals.Fetcher)
-- Yohei Onishi
apache-beam
apache-beam-io
apache-kafka
google-kubernetes-engine
tls1.2

1 Answer

3/8/2019

Seems like a communication issue between to your kafka readers Kafka client may not be able to connect to servers

-- Wisani Salani
Source: StackOverflow