我在启动kafka producer时搜索dns条目(?)时遇到超过4秒的非常奇怪的线程阻塞,异常:
2019-02-11 10:00:33,982 WARN [vertx-blocked-thread-checker] io.vertx.core.impl.BlockedThreadChecker - Thread Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 4172 ms, time limit is 1000 ms
io.vertx.core.VertxException: Thread blocked
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:929)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1324)
at java.net.InetAddress.getAllByName0(InetAddress.java:1277)
at java.net.InetAddress.getAllByName(InetAddress.java:1193)
at java.net.InetAddress.getAllByName(InetAddress.java:1127)
at java.net.InetAddress.getByName(InetAddress.java:1077)
at java.net.InetSocketAddress.<init>(InetSocketAddress.java:220)
at org.apache.kafka.clients.ClientUtils.parseAndValidateAddresses(ClientUtils.java:53)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:406)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:304)
它偶尔发生一次(不是每次)我可以在vertx中以编程方式禁用ipv6查找吗?我怎样才能使这个错误消失?
1条答案
按热度按时间flvlnr441#
添加标志“-djava.net.preferipv4stack=true”后,它修复了问题,但打开了其他一些问题
InetAddress.getLocalHost()
返回localhost\127.0.0.1作为hostname\ip。。。为了解决这个问题,我必须在计算机中编辑/etc/hosts以:在禁用/etc/hosts的所有ipv6部分后,正确的主机名和ip被解析,并且我的程序被正确启动