通过 SOCKS Proxy 连接到 Kafka [英] Connect to Kafka through SOCKS Proxy

查看:62
本文介绍了通过 SOCKS Proxy 连接到 Kafka的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 AWS 上运行的 Kafka 集群.我想使用我的应用程序服务器中的标准 kafka-console-consumer 连接到集群.应用服务器可以通过 SOCKS-Proxy 访问互联网.无需身份验证

I have a Kafka cluster running on AWS. I want to connect to the cluster with the standard kafka-console-consumer from my application server. The application server has access to the internet via a SOCKS-Proxy. No authentication is required

如何告诉 Kafka 客户端通过代理连接?

How do I tell the Kafka client to connect through the proxy?

我尝试了很多方法,包括将标准的 JVM 代理参数添加到 kaka-run-class.sh 脚本中.但我仍然收到连接被拒绝错误.

I tried many things, including adding the standard JVM Proxy parameters to the kaka-run-class.sh script. But I still get a connection refused error.

exec $JAVA -DsocksProxyHost=proxy.host.name -DsocksProxyPort=1080 $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_OPTS -cp $CLASSPATH $KAFKA_OPTS "$@"

事实证明,Kafka 使用了 java.nio 库.它的套接字实现与代理不兼容.所以我用的jvm参数对Kafka客户端没有影响.

It turns out, Kafka uses the java.nio library. It's socket implementation is not compatible with proxies. So the jvm parameters I used have no effect on the Kafka client.

推荐答案

正如评论和编辑中提到的,提问者已经找到了解决方案/根本原因:

As mentioned in comment and edit, the asker already found the solution/root cause:

事实证明,Kafka 使用了 java.nio 库.这是插座实现与代理不兼容.所以jvm参数我used 对 Kafka 客户端没有影响.

It turns out, Kafka uses the java.nio library. It's socket implementation is not compatible with proxies. So the jvm parameters I used have no effect on the Kafka client.

这篇关于通过 SOCKS Proxy 连接到 Kafka的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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