问题
I have installed Kafka 1.1.0 with Zookeeper 3.4.12 under Windows SubSystem for Linux on my Windows 10 laptop. I'm able to procude and consume messages while I stay in ubuntu but when I want to produce a message from windows (with a java program or with the tool kafka-console-producer.bat) I have the following error :
[2018-05-11 15:31:01,449] ERROR Error when sending message to topic test with key: null, value: 15 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback) org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for test-0: 1534 ms has passed since batch creation plus linger time
Any idea ?
回答1:
I had a similar issue and I solved it testing kafka from console like this:
Creating a topic: bin/kafka-topics.sh --zookeeper zooker-domain:2181 --create --topic test --replication-factor 1 --partitions 1
Inserting a message: bin/kafka-console-producer.sh --broker-list kafka-domain:9092 --topic test
Consuming messages: (old api) bin/kafka-console-consumer.sh --zookeeper zookeeper-domain:2181 --topic test --from-beginning
(or with new api) bin/kafka-console-consumer.sh --new-consumer --topic test --from-beginning --bootstrap-server kafka-domain:9092 --partition 0
(Instead of domains you can use directly IPs).
I tested it with kafka 0.11.0.1 and it works.
If you still have problems try with: https://stackoverflow.com/a/51071306/2493852
来源:https://stackoverflow.com/questions/50293757/connection-timeout-with-a-kafka-running-with-windows-subsystem-for-linux