现象

项目启动时出现kafka异常

WARN 17821 --- [gateway-logback] org.apache.kafka.clients.NetworkClient   : [Producer clientId=framework-gateway-logback] Connection to node 0 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
WARN 17821 --- [gateway-logback] org.apache.kafka.clients.NetworkClient   : [Producer clientId=framework-gateway-logback] Connection to node 0 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
WARN 17821 --- [gateway-logback] org.apache.kafka.clients.NetworkClient   : [Producer clientId=framework-gateway-logback] Connection to node 0 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
WARN 17821 --- [gateway-logback] org.apache.kafka.clients.NetworkClient   : [Producer clientId=framework-gateway-logback] Connection to node 0 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.

 

解决方案

  • 修改kafka中server.properties配置,重启kafka,重启项目即可
    # The address the socket server listens on. It will get the value returned from
    # java.net.InetAddress.getCanonicalHostName() if not configured.
    #   FORMAT:
    #     listeners = listener_name://host_name:port
    #   EXAMPLE:
    #     listeners = PLAINTEXT://your.host.name:9092
    listeners=PLAINTEXT://10.10.5.131:9092

     

  • 当kafka节点宕机时,也会出现类似错误。

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐