[英]Kafka remote consumer not getting messages
I have setup 3 node Confluent/Kafka all pointing to the same zookeeper我已经设置了 3 个节点 Confluent/Kafka 都指向同一个 zookeeper
all 3 servers have advertised.listener = public ipv4 with PLAINTEXT所有 3 台服务器都有广告。listener = public ipv4 with PLAINTEXT
server.properties:服务器属性:
broker.id.generation.enable=true
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://PUBLIC-IPv4:9092
listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
zookeeper.connect=10.114.16.19:2181
producer & consumer.properties files have only this value changed producer & consumer.properties 文件仅更改了此值
bootstrap.servers=10.114.16.19:9092,10.114.16.21:9092,10.114.16.20:9092
When I run producer from remote node using node's public ip it works fine, and I can send messages & create topics, but the problem with the consumer its not getting any messages here is the code im using当我使用节点的公共 ip 从远程节点运行生产者时,它工作正常,我可以发送消息并创建主题,但消费者的问题是这里没有收到任何消息是我正在使用的代码
Producer.py生产者.py
producer = KafkaProducer(
bootstrap_servers='PUBLIC-IP:9092',
value_serializer=lambda v: json.dumps(v).encode('utf-8'))
producer.send('slim', {'topic': 'kafka'})
Consumer.py消费者.py
print('Making connection.')
consumer = KafkaConsumer(bootstrap_servers='PUBLIC-IP:9092')
print('Assigning Topic.')
consumer.assign([TopicPartition('slim', 2)])
print('Getting message.')
for message in consumer:
print("OFFSET: " + str(message[0])+ "\t MSG: " + str(message))
when I run the Consumer py client it just stay open and doesnt get any messages Just to clarify the testing code above I found online, I didnt write it since im still learning Kafka API当我运行 Consumer py 客户端时,它只是保持打开状态并且没有收到任何消息只是为了澄清我在网上找到的上面的测试代码,我没有写它,因为我还在学习 Kafka API
First be sure that you can ping PUBLIC-IPPUBLIC-IP
and you are not stuck in a DNS problem.首先确保您可以 ping
PUBLIC-IPPUBLIC-IP
并且您没有陷入 DNS 问题。 Then install kafkacat
if you are on a Linux platform and test if it can consume the data by the following command:如果你在 Linux 平台上,则安装
kafkacat
并通过以下命令测试它是否可以使用数据:
kafkacat -b <BROKER_IP> -t <TOPIC_NAME>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.