Home > front end >  500 Internal Server Error Error while creating AdminClient for Cluster Default
500 Internal Server Error Error while creating AdminClient for Cluster Default

Time:01-14

I get an error when I try to view topics and consumers using UI for apache kafka

docker command i use:

docker run -p 8080:8080 -e KAFKA_CLUSTERS_0_ZOOKEEPER=2181:2181 -e KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=127.0.0.1:9092 -d provectuslabs/kafka-ui:latest

or docker-compose.yml file

services:
  kafka-ui:
    container_name: kafka-ui
    image: provectuslabs/kafka-ui:latest
    ports:
      - 8080:8080
    depends_on:
      - kafka
    environment:
      KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
      KAFKA_CLUSTERS_0_JMXPORT: 9997

  kafka:
    image: johnnypark/kafka-zookeeper
    ports:
      - "2181:2181"
      - "9092:9092"
    network_mode: bridge
    environment:
      ADVERTISED_HOST: 127.0.0.1
      NUM_PARTITIONS: 1
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

I tried both ways, both didn't work

Where did i go wrong?

enter image description here

CodePudding user response:

2181:2181 is two ports, not a Zookeeper hostname/ip and port

Then, Kafka address is referring to the container you're running, not the actual Kafka server. You'll need to modify your Kafka server properties if it's running on the host, and you need to connect from Docker. Related - Connect to Kafka on host from Docker (ksqlDB)

Beyond that, remove the -d or use docker logs to see the actual error.

CodePudding user response:

I was using the johnnypark/kafka-zookeeper library for both kafka and zookeeper. I was able to solve this problem by using two separate libraries as in the example below

  zookeeper1:
    image: confluentinc/cp-zookeeper:5.2.4
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000

  kafka1:
    image: confluentinc/cp-kafka:5.3.1
    depends_on:
      - zookeeper1
    ports:
      - 9093:9093
      - 9998:9998
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper1:2181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:29092,PLAINTEXT_HOST://localhost:9093
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      JMX_PORT: 9998
      KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka1 -Dcom.sun.management.jmxremote.rmi.port=9998

https://github.com/provectus/kafka-ui/blob/master/docker/kafka-ui.yaml

CodePudding user response:

I was using the johnnypark/kafka-zookeeper library for both kafka and zookeeper. I was able to solve this problem by using two separate libraries as in the example below

  zookeeper1:
    image: confluentinc/cp-zookeeper:5.2.4
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000

  kafka1:
    image: confluentinc/cp-kafka:5.3.1
    depends_on:
      - zookeeper1
    ports:
      - 9093:9093
      - 9998:9998
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper1:2181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:29092,PLAINTEXT_HOST://localhost:9093
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      JMX_PORT: 9998
      KAFKA_JMX_OPTS: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka1 -Dcom.sun.management.jmxremote.rmi.port=9998

  •  Tags:  
  • Related