-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kafka producer and consumer not working in TLS enabled cluster #427
Comments
Also no issues noticed with kafka single machine setup with TLS. |
Thanks for the report. I will look into this. |
@kumar-b could you attach your producer send block to |
It gave same error as reported above. |
Hmm are the |
|
Try calling |
Refreshed metadata before call and the topic metadata for three different run is echoed out. $ node ./producer-connect.js 1 test3
sending data to topic- test3
sending data to partition- 1
topic metadata: {"test3":{"0":{"topic":"test3","partition":0,"leader":2,"replicas":[2],"isr":[2]},"1":{"topic":"test3","partition":1,"leader":3,"replicas":[3],"isr":[3]},"2":{"topic":"test3","partition":2,"leader":1,"replicas":[1],"isr":[1]}}}
producer is ready !!!
sending data to partition- 1
/opt/nodetests/kafka-ssl/producer-connect.js:44
throw new Error(err);
^
Error: Error: UnknownTopicOrPartition
at /opt/nodetests/kafka-ssl/producer-connect.js:44:11
at /opt/nodetests/kafka-ssl/node_modules/kafka-node/lib/client.js:194:17
at null.<anonymous> (/opt/nodetests/kafka-ssl/node_modules/kafka-node/lib/client.js:244:31)
at Client.handleReceivedData (/opt/nodetests/kafka-ssl/node_modules/kafka-node/lib/client.js:622:18)
at TLSSocket.<anonymous> (/opt/nodetests/kafka-ssl/node_modules/kafka-node/lib/client.js:594:14)
at emitOne (events.js:77:13)
at TLSSocket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:153:18)
at TLSSocket.Readable.push (_stream_readable.js:111:10)
at TLSWrap.onread (net.js:531:20)
$ node ./producer-connect.js 0 test3
sending data to topic- test3
sending data to partition- 0
topic metadata: {"test3":{"0":{"topic":"test3","partition":0,"leader":2,"replicas":[2],"isr":[2]},"1":{"topic":"test3","partition":1,"leader":3,"replicas":[3],"isr":[3]},"2":{"topic":"test3","partition":2,"leader":1,"replicas":[1],"isr":[1]}}}
producer is ready !!!
sending data to partition- 0
/opt/nodetests/kafka-ssl/producer-connect.js:44
throw new Error(err);
^
Error: Error: UnknownTopicOrPartition
at /opt/nodetests/kafka-ssl/producer-connect.js:44:11
at /opt/nodetests/kafka-ssl/node_modules/kafka-node/lib/client.js:194:17
at null.<anonymous> (/opt/nodetests/kafka-ssl/node_modules/kafka-node/lib/client.js:244:31)
at Client.handleReceivedData (/opt/nodetests/kafka-ssl/node_modules/kafka-node/lib/client.js:622:18)
at TLSSocket.<anonymous> (/opt/nodetests/kafka-ssl/node_modules/kafka-node/lib/client.js:594:14)
at emitOne (events.js:77:13)
at TLSSocket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:153:18)
at TLSSocket.Readable.push (_stream_readable.js:111:10)
at TLSWrap.onread (net.js:531:20)
$ node ./producer-connect.js 2 test3
sending data to topic- test3
sending data to partition- 2
topic metadata: {"test3":{"0":{"topic":"test3","partition":0,"leader":2,"replicas":[2],"isr":[2]},"1":{"topic":"test3","partition":1,"leader":3,"replicas":[3],"isr":[3]},"2":{"topic":"test3","partition":2,"leader":1,"replicas":[1],"isr":[1]}}}
producer is ready !!!
sending data to partition- 2
null { test3: { '2': 8 } } |
the above run was with topic having 1 replication factor and 3 partitions. But same behavior was observed with 3 partitions and 3 replication factor. |
Hi @hyperlink With some debug, I found out the root cause. Since from kafka 0.9 the host and port property were deprecated and listeners was used as single point of truth, we have setup kafka brokers without host and port. So metadata of a broker looks like this way // metadata for leader- 1
{"jmx_port":-1,"timestamp":"1470139709693","endpoints":["SSL://<HOST1>:<PORT1>"],"host":null,"version":3,"port":-1,"sslHost":"<HOST1>","sslPort":<PORT1>} Here host and port are null and -1. In a cluster all the brokers will have host and port as null and -1. var broker = brokers[key];
self.setupBroker(broker.host, broker.port, false, self.brokers); Since all brokers has same null and -1 as host and port, it will be overwritten. Then I hope the analysis will be helpful in fixing the issue. Also please analyze the impact of the same on other parts of the module. |
Actually this is not at all any configuration issue. |
Great debugging @kumar-b. I hope to have this fixed soon. |
@kumar-b could you temporarily point your |
It works with positive tests. I didn't try other negative tests. |
The 3 node kafka cluster is setup with TLS with inter broker communication protocol as SSL. I have created a test topic with 3 partitions and 3 replication factor. The kafka-node producer is able to send message to one of partition, but gives error for other two. Similarly kafka-node consumer is not getting any messages from two of the brokers. kafka console producer and consumers are working fine with the setup.
Please note that kafka-node producer and consumer are working fie with PLAINTEXT kafka listeners.
I am using following code to produce a test message -
It gives following error for partition 0 and 1.
For partition 2, it is able to send the message with no error.
Sometimes with some other topic, we are getting following errors (with stack).
The text was updated successfully, but these errors were encountered: