简体   繁体   English

尝试连接到 AWS EC2 中的 Kafka 时连接被拒绝

[英]Connection refused while trying to connect to Kafka in AWS EC2

I have an AWS EC2 ubuntu instance where it's running zookeeper and kafka.我有一个 AWS EC2 ubuntu 实例,它运行 zookeeper 和 kafka。 I want to connect to kafka from my computer so I have a Java application where I do the connection using kafka api.我想从我的计算机连接到 kafka,所以我有一个 Java 应用程序,我在其中使用 kafka api 进行连接。 When I run the application (from Eclipse) I get the following error:当我运行应用程序(从 Eclipse)时,出现以下错误:

log4j:WARN No appenders could be found for logger (kafka.consumer.SimpleConsumer).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "Timer-0" java.net.ConnectException: Connection refused
at sun.nio.ch.Net.connect0(Native Method)
at sun.nio.ch.Net.connect(Net.java:484)
at sun.nio.ch.Net.connect(Net.java:476)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:675)
at kafka.consumer.SimpleConsumer.connect(SimpleConsumer.scala:49)
at kafka.consumer.SimpleConsumer.getOrMakeConnection(SimpleConsumer.scala:186)
at kafka.consumer.SimpleConsumer.fetch(SimpleConsumer.scala:79)
at kafka.javaapi.consumer.SimpleConsumer.fetch(SimpleConsumer.scala:43)

It seems like this lines are throwing the error:似乎这行正在抛出错误:

FetchRequest req = new FetchRequest("test", 0, offset, 1000);
ByteBufferMessageSet messageSet = simpleConsumer.fetch(req);

Also in the console it says something about log4j.同样在控制台中,它说了一些关于 log4j 的内容。 I have the log4j.properties file in the instance, with the other kafka configuration files.我在实例中有log4j.properties文件,以及其他 kafka 配置文件。 I don't know if it is what is causing this error or if it is something else from the configuration.我不知道是什么导致了这个错误,或者是配置中的其他东西。 I've tried to change hostname to my public IP address in server.properties and the same with broker.list in producer.properties .我试图改变hostname到我的公网IP地址server.properties和相同broker.listproducer.properties

I'm using kafka 0.7.2 version.我正在使用 kafka 0.7.2 版本。

It's solved.解决了。 There was a line in my code trying to connect to localhost instead of the instance public IP.我的代码中有一行试图连接到 localhost 而不是实例公共 IP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS EC2:(连接被拒绝)同时连接到上游 - AWS EC2: (Connection refused) while connecting to upstream 尝试在Docker容器之间进行连接时连接被拒绝(连接被拒绝) - Connection refused (Connection refused) while trying to connect between docker containers 尝试连接到 RDS 时出现 AWS EC2 Interminent UnknownHostException - AWS EC2 Interminent UnknownHostException when trying to connect to RDS Tomcat 8 HTTPS连接在AWS EC2上不起作用 - Tomcat 8 HTTPS connection not working on AWS EC2 AWS-从EC2连接到SQS - AWS - Connect to SQS from EC2 尝试与外部IP连接时连接被拒绝 - Connection refused when trying to connect with an external IP 连接拒绝尝试连接到 mongoDB docker 实例 - Connection refused trying to connect to mongoDB docker instance 连接两个 AWS EC2 实例以将数据从一个 EC2 实例共享到另一个 EC2 实例 - Connect between two AWS EC2 Instances to share data from one EC2 instance to other EC2 instance 无法连接到在 AWS EC2 上运行的 Selenium Grid - Unable to connect to Selenium Grid running on AWS EC2 AWS EC2将无法使用静态访问凭证连接到DynamoDB - AWS EC2 Will Not Connect to DynamoDB using static Access Credentials
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM