kafkatimeouterror('在60.0秒后更新元数据失败')

epfja78i  于 2021-06-07  发布在  Kafka
关注(0)|答案(2)|浏览(1299)

我正在使用python 3.6编写kafka producer,python kafka客户端版本是1.4.4。kafka版本是:2.1.0和1.1.1(尝试了两个版本),但是当我向producer写入消息时,抛出以下错误:

KafkaTimeoutError('Failed to update metadata after 60.0 secs.')

这是我的客户代码:

producer = KafkaProducer(
  bootstrap_servers=['mq-server:9092'],
  api_version = (0,10,2,0) # solve no broker error
)

producer.send("dolphin-test".encode('utf-8'),b"test")

这是我修改的服务器配置:

listeners=PLAINTEXT://10.142.0.2:9092
advertised.listeners=PLAINTEXT://10.142.0.2:9092

当使用脚本生成和使用消息时,它工作得很好!这是客户端跟踪输出:

D:\project\souce\pydolphin-service>D:/Programs/Python/Python37/python.exe d:/project/souce/pydolphin-service/dolphin/producer.py
Traceback (most recent call last):
  File "d:/project/souce/pydolphin-service/dolphin/producer.py", line 14, in <module>
    future = producer.send('my-topic', b'raw_bytes')
  File "D:\Programs\Python\Python37\lib\site-packages\kafka\producer\kafka.py", line 555, in send
    self._wait_on_metadata(topic, self.config['max_block_ms'] / 1000.0)
  File "D:\Programs\Python\Python37\lib\site-packages\kafka\producer\kafka.py", line 682, in _wait_on_metadata
    "Failed to update metadata after %.1f secs." % (max_wait,))
kafka.errors.KafkaTimeoutError: KafkaTimeoutError: Failed to update metadata after 60.0 secs.

我正在搜索谷歌、百度和yandex。

snz8szmq

snz8szmq1#

调整播发配置:

advertised.listeners=PLAINTEXT://external-ip:9092

将nat内网ip修改为公网ip。因为制作人会发信息到这个地址。制片人只能向公众开放。

kknvjkwl

kknvjkwl2#

你的设备箱和Kafka服务器有防火墙吗?你能试试telnet mq服务器9092吗

相关问题