Connect to Kafka inside VirtualBox

I'm having problems connecting my host (Windows) to the guest (Linux) where I installed Kafka.

I created a virtual machine (with VirtualBox) where I installed the Confluent tools. In this virtual machine, I run the command:

confluent start schema-registry

It launches zookeeper, kafka and registry schema.

In this virtual machine, I can run

kafka-console-producer --broker-list localhost:9092 --topic test

and

kafka-console-consumer --bootstrap-server localhost:9092 --topic test

and everything works fine, I can create and receive messages.

My goal, however, is to be able to produce and consume messages from my host, so I configure this port forwarding rule: port forwarding rule

From my Windows, I expected this command to work:

bin\windows\kafka-console-producer.bat --broker-list 127.0.0.1:9092 --topic test

But all I get is:

ERROR Error when sending message to topic test with key: null, value: 3 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for test-0: 1529 ms has passed since batch creation plus linger time 

I tried a lot of different things, but still can not find a solution .... Any ideas?

+4
2

, . Linux?

/ Kafka, Kafka . , / IPAddress.

, , advertised.listeners.

"advertized.listeners" .

+3

- . , , Kafka Zookeeper, .

Kafka Zookeeper, VirtualBox Linux, , Linux. docker-compose.yml :

version: '3'

services:

  zookeeper:
    image: "wurstmeister/zookeeper"
    ports:
      - "2181:2181"

  kafka:
    image: "wurstmeister/kafka"
    ports:
      - "9092:9092"
    environment:
      KAFKA_ADVERTISED_HOST_NAME: "localhost"
      KAFKA_CREATE_TOPICS: "test:1:1"
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181

KAFKA_ADVERTISED_HOST_NAME, , NAT, NAT, VirtualBox ( , 2181 9092 OP). VirtualBox Kafka, "localhost", , , .

1.x - " ", .


, VirtualBox:

port 9092 and 2181 are forwarded

, docker-compose up , / / .

0

Source: https://habr.com/ru/post/1685150/


All Articles