Kafka Broker on Gitpod

huangapple go评论80阅读模式
英文:

Kafka Broker on Gitpod

问题

I've set up a very basic Kafka broker on Gitpod.
我在Gitpod上设置了一个非常基本的Kafka代理。

I would now like to access it from a Python notebook using kafka-python.
我现在想从一个Python笔记本中使用kafka-python访问它。

producer = KafkaProducer(bootstrap_servers=['localhost:9092'])
生产者= KafkaProducer(引导服务器=['localhost:9092'])

I must replace 'localhost' with the IP of my Gitpod workspace, but this would not work 'as is'.
我必须用我的Gitpod工作空间的IP替换'localhost',但这样做不会起作用。

Gitpod provides HTTP endpoints with a format that does not meet the standard/usual connection chain (see below).
Gitpod提供的HTTP端点具有不符合标准/通常连接链的格式(见下文)。

My question is: What should I enter instead of 'localhost' to be able to access my Kafka Broker remotely?
我的问题是:我应该输入什么来代替'localhost'以便能够远程访问我的Kafka Broker?

I would be glad to provide additional context, just ask.
我很乐意提供额外的背景信息,只需提问。

英文:

I've setup a very basic kafka broker on gitpod.<br>
I would now like to access it from a python notebook using kafka-python

producer = KafkaProducer(bootstrap_servers=[&#39;localhost:9092&#39;])

I must replace localhost with the IP of my Gitpod workspace but this would not work 'as is'

Gitpod provides http endpoints with a format that do not meet the standard/usual connection chain (seeb below) <br>
(this is recurring fo all such technologies served on a port, like elasticsearch and such)

My question is : <br>
What should I enter instead of `localhost' to be able to acces my Kafka Broker remotely ?

I would be glad to provide additional context, just ask.

Kafka Broker on Gitpod

答案1

得分: 1

Kafka(也不包括Zookeeper)不是HTTP(S)服务,因此您不能使用这些链接。

仅仅因为某个表中列出了一个转发地址并不应该阻止您访问,但是如果所有服务都作为IDE环境中的外部容器运行,那么localhost将不正确。与其随机设置地址/端口,您需要了解Kafka中advertised.listeners的工作原理,然后连接到那个地址。

英文:

Kafka (nor Zookeeper) are HTTP(S) services, so you cannot use those links.

Just because there's a forwarded address that's listed in some table shouldn't prevent you from accessing, but localhost will not be correct if all services run as external containers from the IDE environment. Rather than randomly set an address/port, you'll need to understand how advertised.listeners works in kafka, then connect to that

huangapple
  • 本文由 发表于 2023年7月6日 18:20:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76627814.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定