Home > Back-end >  Change host protocol from http to https with kafka
Change host protocol from http to https with kafka

Time:10-31

I have a problem with kafka when I work with http protocol kafka run with me without any problem

but after upgrading the protocol from http to https

after upgrade it all services return the same error

2021-10-28 23:16:26.367  WARN 1 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Connection to node 1 (/206.189.178.228:9092) could not be established. Broker may not be available.
2021-10-28 23:18:02.623  WARN 1 --- [ntainer#1-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-2, groupId=groupId] Connection to node 1 (/206.189.178.228:9092) could not be established. Broker may not be available.

in producer and consumer i dont know what happens or if this error appeared from SSL

but i did not change any configuration about Kafka

this is my kafak.yml file

                                                                                   kafka.yml                                                                                               
version: '2'
services:
  zookeeper:
    image: confluentinc/cp-zookeeper:5.5.0
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
    networks:
      - food_default
  kafka:
    image: confluentinc/cp-kafka:5.5.0
    ports:
      - 9092:9092
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ADVERTISED_HOST_NAME: kafka
      LISTENERS: PLAINTEXT://206.189.178.228:9092
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://206.189.178.228:9092
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
    networks:
      - food_default

networks:
  food_default:
    external: true

and this is service config this config existing in each other service

    version: '2'
services:
  food-order-service:
    image: altshiftcreative/food-app-order-service:v1.5
    environment:
      # - _JAVA_OPTIONS=-Xmx512m -Xms256m
      - SPRING_PROFILES_ACTIVE=prod,swagger
      - MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=false
      - EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/eureka
      - SPRING_CLOUD_CONFIG_URI=http://admin:$${jhipster.registry.password}@jhipster-registry:8761/config
      - SPRING_DATASOURCE_URL=jdbc:mysql://food-mysql:3306/food_db?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&useLegacyDatetimeCode=false&serverTimezone=UTC&createD>
      - SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI=https://shopbia.shop/auth/realms/jhipster
      - SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID=internal
      - SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET=internal
      # - JHIPSTER_SLEEP=30 # gives time for other services to boot before the application
      - KAFKA_BOOTSTRAPSERVERS=kafka:9092
    ports:
      - 8082:8082
    networks:
      - food_default
networks:
  food_default:
    external: true

CodePudding user response:

Kafka isn't an HTTP protocol, so your problem has nothing to do with that

You've set KAFKA_BOOTSTRAPSERVERS=kafka:9092

i did not change any configuration about Kafka

I think you did. That IP address is not the default of anything. To revert to expected behavior within the same Docker network, you need to set

LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092

Unclear where you're getting the IP address from, but if you want to expose the Docker container to an external network in that subnet, then you will need other settings

  • Related