如何从外部通过专用网络访问Kafka? [英] How to reach Kafka on private network from outside?

查看:122
本文介绍了如何从外部通过专用网络访问Kafka?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在10.242.44.55的专用网络中有一台带有Zookeeper和Kafka的服务器.我已经将网关上的端口从[public_ip]:39092转发到了10.242.44.55:9092.我从

I have a server with Zookeeper and Kafka in private network on 10.242.44.55. I have forwarded port on gateway from [public_ip]:39092 to 10.242.44.55:9092. I took the following settings for Kafka from another question:

listeners=INTERNAL://:9092,EXTERNAL://:39092
advertised.listeners=INTERNAL://10.242.44.55:9092,EXTERNAL://[public_ip]:39092
listener.security.protocol.map=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
inter.broker.listener.name=INTERNAL

在专用网络中一切正常.我可以产生和使用来自不同计算机的消息.不幸的是,当我尝试从外部发出消息时,出现错误:

Everything works fine in private network. I can produce and consume messages from different computers. Unfortunatelly when I tried to produce a message from outside I got an error:

pers@pc:/opt/kafka$ bin/kafka-console-producer.sh —broker-list [public_ip]:39092 —topic test
>testMessage
>[2018-03-24 17:51:04,393] ERROR Error when sending message to topic test with key: null, value: 11 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for test-1: 1505 ms has passed since batch creation plus linger time
[2018-03-24 17:53:13,970] WARN [Producer clientId=console-producer] Connection to node 0 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)

同时我可以通过telnet访问此套接字:

The same time I can reach this socket with telnet:

pers@pc:/opt/kafka$ telnet [public_ip] 39092
Trying [public_ip]...
Connected to [public_ip].
Escape character is '^]'.
test
Connection closed by foreign host.

我看到另一个人有这样的问题,但没有解决方案. 有人知道我在做什么吗?

I saw that another man had such problem, but there are no solutions. Anybody knows what I'm doing worng?

推荐答案

我不小心解决了我的问题.当在端口转发中使用相同的端口时,Kafka可以正常工作.

I accidentally solved my problem. Kafka works fine when the same ports are used in ports forwarding.

这是我的经纪人配置的一部分:

This is part of my broker's config:

listeners=EXTERNAL://:39092,INTERNAL://:9092
advertised.listeners=EXTERNAL://77.1.1.1:39092,INTERNAL://10.1.1.1:9092
listener.security.protocol.map=EXTERNAL:PLAINTEXT,INTERNAL:PLAINTEXT
inter.broker.listener.name=INTERNAL

这篇关于如何从外部通过专用网络访问Kafka?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆