Support Questions

Find answers, ask questions, and share your expertise

kafka-console-producer.sh

avatar
Explorer

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. 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

avatar
Expert Contributor
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

View solution in original post

4 REPLIES 4

avatar
Expert Contributor
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

avatar
Explorer

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 

 

 

avatar
Expert Contributor
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

avatar
Explorer

Hi Jerry, 

 

It has starting working after I changed the property "offsets.topic.replication.factor" 3 to 1. 

 

Thanks for your support.

 

Aamir.