[英]Connect to Kafka through SOCKS Proxy
I have a Kafka cluster running on AWS.我有一个在 AWS 上运行的 Kafka 集群。 I want to connect to the cluster with the standard kafka-console-consumer from my application server.
我想从我的应用程序服务器使用标准的kafka-console-consumer连接到集群。 The application server has access to the internet via a SOCKS-Proxy.
应用服务器可以通过 SOCKS-Proxy 访问互联网。 No authentication is required
无需身份验证
How do I tell the Kafka client to connect through the proxy?如何告诉 Kafka 客户端通过代理连接?
I tried many things, including adding the standard JVM Proxy parameters to the kaka-run-class.sh script.我尝试了很多方法,包括将标准的 JVM 代理参数添加到kaka-run-class.sh脚本中。 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 "$@"
Edit: It turns out, Kafka uses the java.nio library.编辑:事实证明,Kafka 使用 java.nio 库。 It's socket implementation is not compatible with proxies.
它的套接字实现与代理不兼容。 So the jvm parameters I used have no effect on the Kafka client.
所以我用的jvm参数对Kafka客户端没有影响。
As mentioned in comment and edit, the asker already found the solution/root cause:正如评论和编辑中提到的,提问者已经找到了解决方案/根本原因:
It turns out, Kafka uses the java.nio library.
事实证明,Kafka 使用了 java.nio 库。 It's socket implementation is not compatible with proxies.
它的套接字实现与代理不兼容。 So the jvm parameters I used have no effect on the Kafka client.
所以我用的jvm参数对Kafka客户端没有影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.