kafka Failed to send messages after 3 tries.

在kafka0.8开发过程中 生产者测试用例碰到了

Exception in thread "main" kafka.common.FailedToSendMessageException: Failed to send messages after 3 tries.
at kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:90)
at kafka.producer.Producer.send(Producer.scala:76)
at kafka.javaapi.producer.Producer.send(Producer.scala:33)
at com.tuan55.kafka.test.TestP.main(TestP.java:20)

这样的错误。

起初以为是网络问题,经确认网络没有问题。

Properties props = new Properties();
props.put("metadata.broker.list", "xx.xx.xx.xx:9092");
props.put("serializer.class", "kafka.serializer.StringEncoder");
props.put("request.required.acks", "1");
ProducerConfig config = new ProducerConfig(props);
Producer<String, String> producer = new Producer<String, String>(config);
KeyedMessage<String, String> km = new KeyedMessage<String, String>("mm", "key-1", "content-1-中文");
producer.send(km);

producer.close();

这是生产者的代码 在向服务器发起连接后,在kafka的服务器配置中有zookeeper.connect=xx.xx.xx.xx:2181的配置 这时候kafka会查找zookeeper

那么如果我们的hosts 中没有做hosts的配置 kafka经多次尝试连接不上就会报上面的错误。

解决办法:配置hosts文件 做zookeeper服务器的映射配置。

出现此种错误 还有一种情况

# Hostname the broker will advertise to producers and consumers. If not set, it uses the
# value for "host.name" if configured.  Otherwise, it will use the value returned from
# java.net.InetAddress.getCanonicalHostName().
advertised.host.name=192.168.1.118

远程连接的话 是根据这个配置来找broker的,默认是localhost ,所以如果不是本机运行的话 应该设置此值 来确保通信畅通。

kafka Failed to send messages after 3 tries 问题解决的更多相关文章

  1. 开发环境解决 kafka Failed to send messages after 3 tries

    新建了一个kafka集群,在window下写了一个简单的producer做测试,结果遇到了消息发送失败的问题,代码如下: Properties props = new Properties(); pr ...

  2. kafka.common.FailedToSendMessageException: Failed to send messages after 3 tries.

    今天在写kafka生产者生成数据的程序并运行时,报如下错误: log4j:WARN No appenders could be found for logger (kafka.utils.Verifi ...

  3. kafka.common.FailedToSendMessageException: Failed to send messages after 3 tries. 最无语的配置

    注意: 本文不谈废话,低级问题请自行检查. 我使用Java版本的Kafka Producer生产数据,但是抛出了这个异常.百思不得其解,明明防火墙配置,ZooKeeper,Kafka配置都是没问题的啊 ...

  4. Thread-0" kafka.common.FailedToSendMessageException: Failed to send messages after 3 tries.

    http://blog.csdn.net/jingshuigg/article/details/25001979 zookeeper.connect=localhost:2181改成zookeeper ...

  5. Caused by java.lang.Exception Failed to send data to Kafka Expiring

    flink 写kafka,报错,作业挂掉 Caused by: java.lang.Exception: Failed to send data to Kafka: Expiring 89 recor ...

  6. lr11 BUG?Failed to send data by channels - post message failed.

    问题描述   : http协议,场景运行一会之后,报错! erro信息: Failed to send data by channels - post message failed. 解决方法 :ht ...

  7. org.apache.flume.EventDeliveryException: NettyAvroRpcClient { host: hadoop1, port: 41414 }: Failed to send event

    org.apache.flume.EventDeliveryException: NettyAvroRpcClient { host: hadoop1, port: 41414 }: Failed t ...

  8. windows elasticsearch搭集群启动失败failed to send join request to master....

    创建几份elasticsearch副本,修改各自config\elasticsearch.yml配置文件: 第一份: #允许elasticsearch跨域访问,使用elasticsearch-head ...

  9. VirtualBox问题解决合集 - [drm:vmw_host_log [vmwgfx]] *ERROR* Failed to send host log message

    转载:https://blog.csdn.net/mychangee/article/details/104954262 问题描述:[drm:vmw_host_log [vmwgfx]] ERROR  ...

随机推荐

  1. MongoDB的用户管理(6)

    注意: A)在mongodb中,有一个admin数据库, 牵涉到服务器配置层面的操作,需要先切换到admin数据. 即 use admin , -->相当于进入超级用户管理模式. B)mongo ...

  2. 主动模式FTP与被动模式FTP该如何选择

    主动模式FTP与被动模式FTP该如何选择  无论是主动模式还是被动模式,其要进行文件传输都必须依次建立两个连接,分别为命令连接与数据连结.而主动模式与被动模式的差异主要体现在数据连结通道上.为了说明两 ...

  3. SASS 编译后去掉缓存文件和map文件

    编译的时候加参数 --sourcemap=none --no-cache 就可以了

  4. 解决VS+opencv中Debug版本与Release版本lib切换的问题

    Author: Maddock Date: 2015-03-26 09:34:48 问题来源:http://bbs.csdn.net/topics/390733725 PS: 按照上述方法做的时候,在 ...

  5. LeetCode——Best Time to Buy and Sell Stock II (股票买卖时机问题2)

    问题: Say you have an array for which the ith element is the price of a given stock on day i. Design a ...

  6. div滚动底部加载li,window滚动底部加载li

    DIV固定高度滚动条滚动最底部,加载新的li <!DOCTYPE html> <html> <head> <meta charset="UTF-8& ...

  7. 【maven】maven创建web项目-pom文件提示web.xml is missing and <failOnMissingWebXml> is set to true

    使用maven创建web项目,选择war类型后,pom文件红叉 提示web.xml is missing and <failOnMissingWebXml> is set to true ...

  8. hdu 3632 A Captivating Match(区间dp)

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=3632 题意:n个人进行比赛,每个人有一个价值a[i],最后冠军只有一个,只能相邻两个人进行 ...

  9. Appium中部分api的使用方法

    使用的语言是java,appium的版本是1.3.4,java-client的版本是java-client-2.1.0,建议多参考java-client-2.1.0-javadoc. 1.使用Andr ...

  10. 数位DP GYM 100827 E Hill Number

    题目链接 题意:判断小于n的数字中,数位从高到低成上升再下降的趋势的数字的个数 分析:简单的数位DP,保存前一位的数字,注意临界点的处理,都是套路. #include <bits/stdc++. ...