Question

In my java web app I'm trying to send message so kafka (Ver 7.2). I'm using zoo keeper to connect to my brokers as follows:

props = new Properties();
props.put("zk.connect", <zk-ip1>:<2181>,<zk-ip3>:<2181>,<zk-ip3>:<2181>);
props.put("zk.connectiontimeout.ms", "1000000");
props.put("producer.type", "async");

Producer<String, Message> producer = new kafka.javaapi.producer.Producer<String, Message>(new ProducerConfig(props));

ProducerData<String, Message> producerData = new ProducerData<String, Message>("someTopic", messageTosend);

producer.send(producerData);

As I create the producer the logs looks fine:

    27 Jan 2014 07:38:25  INFO ZooKeeper - Initiating client connection, connectString=<zk-ip1>:2181,<zk-ip2>:2181,<zk-ip3>:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@2a2fd6f7
    27 Jan 2014 07:38:25  INFO ClientCnxn - Opening socket connection to server /<zk-ip2>:2181
    27 Jan 2014 07:38:25  INFO ClientCnxn - Socket connection established to <zp-ipk>/<zk-ip2>:2181, initiating session
    27 Jan 2014 07:38:25  INFO ClientCnxn - Session establishment complete on server <zk-ip2>/<zp-ip2>:2181, sessionid = 0x143b94e6434000c, negotiated timeout = 6000
    27 Jan 2014 07:38:25  INFO ZkClient - zookeeper state changed (SyncConnected)
    27 Jan 2014 07:38:25  INFO ProducerPool - Creating async producer for broker id = 326278963 at <broker-ip2>:9092
    27 Jan 2014 07:38:25  INFO ProducerPool - Creating async producer for broker id = 936343853 at <broker-ip1>:9092

But when trying to send a message I get:

27 Jan 2014 07:39:07  INFO SyncProducer - Disconnecting from <broker-ip2>:9092
27 Jan 2014 07:39:07 ERROR SyncProducer - Connection attempt to <broker-ip2>:9092 failed, next attempt in 100 ms
java.nio.channels.UnresolvedAddressException
        at sun.nio.ch.Net.checkAddress(Net.java:127)
        at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:640)
        at kafka.producer.SyncProducer.connect(SyncProducer.scala:173)
        at kafka.producer.SyncProducer.getOrMakeConnection(SyncProducer.scala:196)
        at kafka.producer.SyncProducer.send(SyncProducer.scala:92)
        at kafka.producer.SyncProducer.multiSend(SyncProducer.scala:135)
        at kafka.producer.async.DefaultEventHandler.send(DefaultEventHandler.scala:58)
        at kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:44)
        at kafka.producer.async.ProducerSendThread.tryToHandle(ProducerSendThread.scala:116)
        at kafka.producer.async.ProducerSendThread$$anonfun$processEvents$3.apply(ProducerSendThread.scala:95)
        at kafka.producer.async.ProducerSendThread$$anonfun$processEvents$3.apply(ProducerSendThread.scala:71)
        at scala.collection.immutable.Stream.foreach(Stream.scala:526)
        at kafka.producer.async.ProducerSendThread.processEvents(ProducerSendThread.scala:70)
        at kafka.producer.async.ProducerSendThread.run(ProducerSendThread.scala:41)

Any ideas?

Was it helpful?

Solution

Problem solved. It appears we had some internal IT issues with DNS configurations (that relates to our zk and brokers).

OTHER TIPS

I had the same issue. After some investigation, I found that I forgot to set the host.name or advertised.host.name property in Kafka broker configuration file, by default the configuration file is server.properties.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top