Accessing kafka in sandbox from Host OS (after trying every solution)

爷,独闯天下 提交于 2019-12-11 12:23:02

问题


Cnsider me a noob. I have read all the issues on stack overflow and tried for one day but the solution just do not click to me. PLEASE Help me specifically to my SETTINGS and CODE(because I have tried all possibilities from same issues on stack overflow - )

This is my Producer.properties file

This is my server.properties file

This is my code

Properties props = new Properties();
props.put("metadata.broker.list", "sandbox.hortonworks.com:9093");
//props.put("zk.connect", "sandbox.hortonworks.com:2181");
props.put("serializer.class", "kafka.serializer.StringEncoder");
props.put("request.required.acks", "1");

KeyedMessage<String, String> data = new KeyedMessage<String, String> (topic1,"ccccccccc");


System.out.println(data);
producer.send(data);

This is the eclipse output

KeyedMessage(tweeter,null,ccccccccc)
kafka.common.FailedToSendMessageException: Failed to send messages after 3 tries.

回答1:


@Samhash, as per my understanding advertised.host.name should be an IP address which is pingable from your local machine. To your local machine, I don't think so sandbox.hortonworks.com will be understood or you may have to make an entry for this host in your local machine.
Please let me know if it works for you.




回答2:


Well in Hit and Trail strategy I finally Caught the problem.

There are 4 properties in server.properties file port, host.name, advertised host name and advertised port

And 1 property in Producer.properties file metadata.broker.list

Make sure that broker.list is same as advertised.host.name:advertised.port

Comment host.name property as it doesn't effect If advertised host name is given.

I simply got ip of my sandbox using ifconfig command and then put that IP with 9092 port in both properties and it worked.



来源:https://stackoverflow.com/questions/32602107/accessing-kafka-in-sandbox-from-host-os-after-trying-every-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!