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

相關文章
相關標籤/搜索