Facing Error in Kafka Producer

[Copied from internal discussion]

I am getting a error while running kafka

[user246388@cxln4 bin]$ kafka-console-producer.sh --broker-list cxln4.c.thelab-240901.internal:6667 --topic user2495
hey
[2019-09-11 09:49:31,706] ERROR Error when sending message to topic rinki2495 with key: null, value: 3 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.

Though this command is just working fine for me right now, this usually happens when the corresponding broker is dead.

So, to be on the safer side at least mention more than 1 broker like this:

kafka-console-producer.sh --broker-list cxln1.c.thelab-240901.internal:6667,cxln4.c.thelab-240901.internal:6667 --topic user2495

You can find the IP addresses or names of brokers from zookeeper using the following commands:

[sandeepgiri9034@cxln4 ~]$ zookeeper-client
.... loads of text scrolls ....
[zk: localhost:2181(CONNECTED) 1] ls /brokers
[ids, topics, seqid]
[zk: localhost:2181(CONNECTED) 2] ls /brokers/ids
[1004, 1003]
[zk: localhost:2181(CONNECTED) 3] get /brokers/ids/1004
{"jmx_port":-1,"timestamp":"1567071897835","endpoints":["PLAINTEXT://cxln2.c.thelab-240901.internal:6667"],"host":"cxln2.c.thelab-240901.internal","version":3,"port":6667,"rack":"/default-rack"}
cZxid = 0x80000c374
ctime = Thu Aug 29 09:44:57 UTC 2019
mZxid = 0x80000c374
mtime = Thu Aug 29 09:44:57 UTC 2019
pZxid = 0x80000c374
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x26cdcc113f60002
dataLength = 194
numChildren = 0
[zk: localhost:2181(CONNECTED) 4] get /brokers/ids/1003
{"jmx_port":-1,"timestamp":"1568009036849","endpoints":["PLAINTEXT://cxln1.c.thelab-240901.internal:6667"],"host":"cxln1.c.thelab-240901.internal","version":3,"port":6667,"rack":"/default-rack"}
cZxid = 0x8000b715b
ctime = Mon Sep 09 06:03:56 UTC 2019
mZxid = 0x8000b715b
mtime = Mon Sep 09 06:03:56 UTC 2019
pZxid = 0x8000b715b
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x46cd94b105902a8
dataLength = 194
numChildren = 0
[zk: localhost:2181(CONNECTED) 5]