Muhunthan
Muhunthan

Reputation: 413

kafka consumer not receiving message over remote

Hi I'm new to kafka and I have a quick question.

I implemented a kafka producer and consumer zookeeper and producer is running in another server (192.168.10.233) Consumer is running in another server (192.168.10.234) Both are locally connected

Problem is Consumer get connected with producer but not listening any message but if I move this listening part to same server (192.168.10.233) , it is receiving the messages

this is my code for consumer

def listen(): Unit = {
    val props = new Properties();
    props.put("bootstrap.servers", "192.168.10.233:9092");
    props.put("group.id", "groupId");
    props.put("enable.auto.commit", "true");
    props.put("auto.commit.interval.ms", "1000");
    props.put("session.timeout.ms", "30000");
    props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
    props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
    val consumer = new KafkaConsumer(props);

    println("calling ---- but yet to receive the message")

    consumer.subscribe(List("test"));
    while (true) {
      val records = consumer.poll(100);
      for (record <- records)
      println("offset = %d, key = %s, value = %s", record.offset(), record.key(), record.value());
    }

  }

I also checked 192.168.10.233:9092 from outside ,weather the port is not blocked by anything.

Upvotes: 1

Views: 2514

Answers (1)

serejja
serejja

Reputation: 23841

Most likely you have to set advertised.host.name in your kafka/config/server.properties to a value that is routable from outside.

Upvotes: 2

Related Questions