[英]Python Kafka client cannot connect to remote Kafka server
我在云上有一个 Ubuntu VM,我从 Kafka官方网站下载了 Kafka 2.8.1 版,并按照Kafka 官方快速入门指南中的说明进行操作。
我正在使用 python 客户端来使用我在快速入门指南中创建的主题之一。 当我在 VM 上运行它时,一切运行正常,但是,当我在本地系统上运行相同的程序时,出现以下错误
Unable connect to node with id 0: [Errno 8] nodename nor servname provided, or not known
Traceback (most recent call last):
...
...
File "/Path/python3.9/site-packages/aiokafka/client.py", line 547, in check_version
raise KafkaConnectionError(
kafka.errors.KafkaConnectionError: KafkaConnectionError: No connection to node with id 0
我正在使用的 python 程序:
import asyncio
import aiokafka
async def consume(self):
consumer = aiokafka.AIOKafkaConsumer(
"quickstart-events", bootstrap_servers="IP:9092"
)
try:
await consumer.start()
async for msg in self.consumer:
print(
"consumed: ",
msg.topic,
msg.partition,
msg.offset,
msg.key,
msg.value,
msg.timestamp,
)
finally:
await consumer.stop()
asyncio.run(consume())
我已确保 Ubuntu 上的必要端口 (9022) 已打开 - 我检查了我是否可以从本地系统将 te.net 连接到端口 9022。
我不确定我无法通过 inte.net 访问 Kafka 的原因是什么。 我错过了一些明显的东西吗?
将config/server.properties
中的以下属性更改为您在代码中使用的引导服务器地址。
advertised.listeners = PLAINTEXT://IP or FQDN:9092
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.