Skip to main content
aamsoh
Silver ⭐️⭐️
June 9, 2019
Solved

kafka-console-producer.sh

Hi, 

 

I am not able to produce the msg on cloudera. I am running below command get the error. 

 

COMMAND:

kafka-console-producer.sh \
--broker-list localhost:9092 \
--topic kafkademo1

 

ERRPR MSG: 

 

WARN [Producer clientId=console-producer] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)

 

 

 

Need support in this regard. 

 

 

 

 

 

 

 

Jerry
JerryAnswer
Gold ⭐️
June 11, 2019
Hi,

Please use the below steps if your cluster is unsecure.

kafka-topics --create --zookeeper <zk host>:2181 --replication-factor 3 --partitions 1 --topic Testmessage

Run a Kafka console producer:
$ kafka-console-producer --broker-list <broker hostnome>:9092 --topic Testmessage
 
Run a Kafka console consumer:
$ kafka-console-consumer --new-consumer --topic Testmessage --from-beginning --bootstrap-server <broker hostnome>:9092

Thanks
Jerry

4 replies

Jerry
Gold ⭐️
Gold ⭐️
June 10, 2019
Hi,

From the logs, It seems its unable to find the broker "Connection to node -1 (localhost/127.0.0.1:9092) could not be established"

Make sure you have broker running in the node and listening to 9092
Also try adding the fully qualified name or IP instead of localhost

Thanks
Jerry
Translate
aamsoh
aamsohAuthor
Silver ⭐️⭐️
June 11, 2019

Hi Jerry, 

 

After replacing localhost to hostname "quickstart.cloudera" it is working , but now I am not getting messages in my consumers terminal. I follow the below commands. 

 

 

kafka-console-producer.sh --broker-list quickstart.cloudera:9092 --topic test-1
>welcome to
>

 

 

kafka-console-consumer.sh --bootstrap-server quickstart.cloudera:9092 --topic test-1 --from-beginning

 

 

Pleaes let me know what could be the problem. 

 

Regards, 

 

Aamir 

 

 

Translate
Jerry
Gold ⭐️
JerryAnswer
Gold ⭐️
June 11, 2019
Hi,

Please use the below steps if your cluster is unsecure.

kafka-topics --create --zookeeper <zk host>:2181 --replication-factor 3 --partitions 1 --topic Testmessage

Run a Kafka console producer:
$ kafka-console-producer --broker-list <broker hostnome>:9092 --topic Testmessage
 
Run a Kafka console consumer:
$ kafka-console-consumer --new-consumer --topic Testmessage --from-beginning --bootstrap-server <broker hostnome>:9092

Thanks
Jerry
Translate