开发者社区> 问答> 正文

kafka客户端连接失败?报错

1、远程服务器安装的zookeeper和kafka,在服务器上启动生产者和消费者之间是正常的可以通信

2、使用java写kafka的客户端,一直连接不上远程kafka服务器

2018-08-15 13:14:57,471 (kafka-producer-network-thread | producer-1) [DEBUG - org.apache.kafka.common.network.Selector.poll(Selector.java:307)] Connection with /ip地址 disconnected
java.net.ConnectException: Connection refused: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:54)
    at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:72)
    at org.apache.kafka.common.network.Selector.poll(Selector.java:274)
    at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:256)
    at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:216)
    at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:128)
    at java.lang.Thread.run(Thread.java:748)

3、修改了server.properties文件,增加了 host.name=服务器ip 配置,启动kafka报错

[2018-08-15 14:01:14,781] ERROR [KafkaServer id=0] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
org.apache.kafka.common.KafkaException: Socket server failed to bind to 服务器ip:9092: Cannot assign requested address.
        at kafka.network.Acceptor.openServerSocket(SocketServer.scala:442)
        at kafka.network.Acceptor.<init>(SocketServer.scala:332)
        at kafka.network.SocketServer.$anonfun$createAcceptorAndProcessors$1(SocketServer.scala:149)
        at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:59)
        at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:52)
        at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
        at kafka.network.SocketServer.createAcceptorAndProcessors(SocketServer.scala:145)
        at kafka.network.SocketServer.startup(SocketServer.scala:94)
        at kafka.server.KafkaServer.startup(KafkaServer.scala:250)
        at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:38)
        at kafka.Kafka$.main(Kafka.scala:75)
        at kafka.Kafka.main(Kafka.scala)
Caused by: java.net.BindException: Cannot assign requested address
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:433)
        at sun.nio.ch.Net.bind(Net.java:425)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:67)
        at kafka.network.Acceptor.openServerSocket(SocketServer.scala:438)
        ... 11 more

配置文件再没有其他的改动了,求大神指点迷津~~~

展开
收起
爱吃鱼的程序员 2020-06-06 15:48:18 1910 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>怎么没有人回答呢。。。。。。。。。。。。。</p>
    
                    
    
                        <p>先测试一下网络是否能连接 telnet 一下,是否开着防火墙</p> 
    

    或者 去服务器,修改config/server.properties配置文件,更改如下
    把31行的注释去掉,listeners=PLAINTEXT://:9092
    把36行的注释去掉,把advertised.listeners值改为PLAINTEXT://host_ip:9092

    2020-06-06 15:48:32
    赞同 1 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Java Spring Boot开发实战系列课程【第16讲】:Spring Boot 2.0 实战Apache Kafka百万级高并发消息中间件与原理解析 立即下载
MaxCompute技术公开课第四季 之 如何将Kafka数据同步至MaxCompute 立即下载
消息队列kafka介绍 立即下载