如何解决Kafkatimeouterror:在60.0秒后无法更新元数据?

发布于 2025-02-07 23:52:58 字数 2284 浏览 2 评论 0 原文

我正在尝试使用Kafka-Python向我的AWS MSK无服务器集群发送消息。 我已经通过以下本指南创建了MSK无服务器集群: https://docs.aws.amazon.com/msk/latest/developerguide/msk-serverless-produce-consume.html

我的群集处于活动状态,我在同一VPC和VPC和与我的集群相同的子网。我已经通过使用命令行(教程中的步骤5)创建了一个成功发送给它的主题和红色消息。

现在,我需要使用Python做同样的事情。因此,我尝试执行以下操作:

from kafka import KafkaProducer
cluster_endpoint = 'boot-name.c1.kafka-serverless.reagion-name.amazonaws.com:9098'
producer = KafkaProducer(security_protocol="SSL",bootstrap_servers=[cluster_endpoint])
producer.send('my-topic-name', "test message")

但是在这一点上,我收到

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ec2-user/.local/lib/python3.7/site-packages/kafka/producer/kafka.py", line 576, in send
    self._wait_on_metadata(topic, self.config['max_block_ms'] / 1000.0)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/kafka/producer/kafka.py", line 703, 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.

我注意到端口通常是 9091 9092 ,但是当我转到“查看客户端信息”时对于我的群集,我的端点是我在代码中使用 9098 端口号码所写的。

我在这里遵循不同的建议,但没有任何帮助。 这就是我尝试的:

丢失的?

I'm trying to send messages using kafka-python to my AWS MSK Serverless cluster.
I've created MSK Serverless cluster by following this guide: https://docs.aws.amazon.com/msk/latest/developerguide/msk-serverless-produce-consume.html

My cluster is in active state and I have an EC2 instance in the same VPC and with the same subnet as my cluster. I've created a topic an successfully sent and red messages to it and from it by using the command line (Step 5 in the tutorial).

Now I need to do the same using python. So I tried to do the following:

from kafka import KafkaProducer
cluster_endpoint = 'boot-name.c1.kafka-serverless.reagion-name.amazonaws.com:9098'
producer = KafkaProducer(security_protocol="SSL",bootstrap_servers=[cluster_endpoint])
producer.send('my-topic-name', "test message")

But at this point I receive

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ec2-user/.local/lib/python3.7/site-packages/kafka/producer/kafka.py", line 576, in send
    self._wait_on_metadata(topic, self.config['max_block_ms'] / 1000.0)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/kafka/producer/kafka.py", line 703, 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.

I've noticed that usually the port is 9091 or 9092 but when I go to "View client information" for my cluster my endpoint is as I wrote in my code with 9098 port number.

I tied to follow different advises here but nothing had helped.
This is what I've tried:

What am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文