kafka调试中遇到could not be established. Broker may not be available. (org.apache.kafka.clients.Networ...


启动生产者命令:java

kafka-console-producer.bat --broker-list localhost:9092 --topic haha


启动消费者:bootstrap

kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic haha --from-beginning

kafka 配置文件:socket

############################# Socket Server Settings ############################# # 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://localhost:9092
 # Hostname and port the broker will advertise to producers and consumers. If not set, # it uses the value for "listeners" if configured. Otherwise, it will use the value # returned from java.net.InetAddress.getCanonicalHostName(). #advertised.listeners=PLAINTEXT://your.host.name:9092
 # 外部代理地址 advertised.listeners=PLAINTEXT://localhost:9092
# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details #listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL

解决办法:spa

消费者代码:.net

kafka-console-consumer.bat --bootstrap-server PLAINTEXT://localhost:9092 --topic haha --from-beginning

疑问:?代理

这里比较奇怪; 生产者没有加PLAINTEXT:// 可以正常启动 在消费者竟然可以报错? 诡异code

kafka 版本:"server

kafka_2.13-2.4.0\kafka-logs"blog

相关文章
相关标签/搜索