0

I'm trying to integrate spring kafka into my spring boot application. It seems like my setting in application.yml "spring.kafka.boostrap-servers: 192.169.116.1:29092" does not work. Here is the log of my application

ConsumerClientConfig

2021-05-26 01:58:39.418  INFO 23470 --- [           main] o.a.k.clients.consumer.ConsumerConfig    : ConsumerConfig values:
        allow.auto.create.topics = false
        auto.commit.interval.ms = 5000
        auto.offset.reset = latest
        bootstrap.servers = [192.168.116.1:29092]
        check.crcs = true
        client.dns.lookup = default
        client.id =
        client.rack =
        connections.max.idle.ms = 540000
        default.api.timeout.ms = 60000
        enable.auto.commit = false
        exclude.internal.topics = true
        fetch.max.bytes = 52428800
        fetch.max.wait.ms = 500
        fetch.min.bytes = 1
        group.id = listener1
        group.instance.id = null
        heartbeat.interval.ms = 3000
        interceptor.classes = []
        internal.leave.group.on.close = true
        isolation.level = read_uncommitted
        key.deserializer = class org.apache.kafka.common.serialization.StringDeserializer
        max.partition.fetch.bytes = 1048576
        max.poll.interval.ms = 300000
        max.poll.records = 500
        metadata.max.age.ms = 300000
        metric.reporters = []
        metrics.num.samples = 2
        metrics.recording.level = INFO
        metrics.sample.window.ms = 30000
        partition.assignment.strategy = [class org.apache.kafka.clients.consumer.RangeAssignor]
        receive.buffer.bytes = 65536
        reconnect.backoff.max.ms = 1000
        reconnect.backoff.ms = 50
        request.timeout.ms = 30000
        retry.backoff.ms = 100
        sasl.client.callback.handler.class = null
        sasl.jaas.config = null
        sasl.kerberos.kinit.cmd = /usr/bin/kinit
        sasl.kerberos.min.time.before.relogin = 60000
        sasl.kerberos.service.name = null
        sasl.kerberos.ticket.renew.jitter = 0.05
        sasl.kerberos.ticket.renew.window.factor = 0.8
        sasl.login.callback.handler.class = null
        sasl.login.class = null
        sasl.login.refresh.buffer.seconds = 300
        sasl.login.refresh.min.period.seconds = 60
        sasl.login.refresh.window.factor = 0.8
        sasl.login.refresh.window.jitter = 0.05
        sasl.mechanism = GSSAPI
        security.protocol = PLAINTEXT
        security.providers = null
        send.buffer.bytes = 131072
        session.timeout.ms = 10000
        ssl.cipher.suites = null
        ssl.enabled.protocols = [TLSv1.2]
        ssl.endpoint.identification.algorithm = https
        ssl.key.password = null
        ssl.keymanager.algorithm = SunX509
        ssl.keystore.location = null
        ssl.keystore.password = null
        ssl.keystore.type = JKS
        ssl.protocol = TLSv1.2
        ssl.provider = null
        ssl.secure.random.implementation = null
        ssl.trustmanager.algorithm = PKIX
        ssl.truststore.location = null
        ssl.truststore.password = null
        ssl.truststore.type = JKS
        value.deserializer = class org.apache.kafka.common.serialization.StringDeserializer

Error during connection

2021-05-26 01:58:40.543  WARN 23470 --- [listener1-0-C-1] org.apache.kafka.clients.NetworkClient   : [Consumer clientId=consumer-listener1-1, groupId=listener1] Connection to node 1 (localhost/127.0.0.1:29092) could not be established. Broker may not be available.

you may notice the server address has changed to localhost(127.0.0.1) I would like to know what makes this inconsistence?

zhili
  • 21
  • 1

1 Answers1

2

emmm...I realize what's wrong. Well, I'm using a kafka server provided by confulentinc running in docker. And kafka is not remote accessable by default. You have to put a "advertised.listeners" setting in kafka/config/server.properties. In my case, I put "advertised.listeners=PLAINTEXT://192.168.116.130:9092 ". Now, it works

zhili
  • 21
  • 1