Kafka-node: Empty messages

Created on 7 Sep 2018  路  5Comments  路  Source: SOHU-Co/kafka-node

Bug Report

Hello!
I've tried to interact with kafka in docker from cp-docker-images (branch 5.0.0-post). I've implement simple message listening code:

const client = new kafka.Client("zookeeper:2181");
const consumer = new kafka.Consumer(client, [{ topic: "test30", partition: 0 }], { autoCommit: false });

consumer.on("message", (message) => {
      console.log("Got message", message)
});

Then I've run docker and create topic

$ docker-compose up -d
$ docker-compose exec broker kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic test30

Then I've send one message:

$ docker-compose exec broker kafka-console-producer --broker-list localhost:9092 --topic test30
>hello!

And this is what I've got:

$ node .
Got message { topic: 'test30',
  value: 'hello!',
  offset: 0,
  partition: 0,
  highWaterOffset: 1,
  key: null }
Got message { topic: 'test30',
  value: '',
  offset: 0,
  partition: 0,
  highWaterOffset: 1,
  key: '' }

Two messages one of them has zero message and offset.
If I try consumer manually I've got just one message:

$ docker-compose exec broker kafka-console-consumer --bootstrap-server localhost:9092 --topic test30 --from-beginning
hello!
^CProcessed a total of 1 messages

But it's getting worse when I try to send one more message it start to emitting 'message' signal infinitely:

...
Got message { topic: 'test30',
  value: 'world',
  offset: 1,
  partition: 0,
  highWaterOffset: 2,
  key: null }
Got message { topic: 'test30',
  value: '',
  offset: 0,
  partition: 0,
  highWaterOffset: 2,
  key: '' }
Got message { topic: 'test30',
  value: 'world',
  offset: 1,
  partition: 0,
  highWaterOffset: 2,
  key: null }
Got message { topic: 'test30',
  value: '',
  offset: 0,
  partition: 0,
  highWaterOffset: 2,
  key: ''
... 

How can I handle that?
Best regards!

Environment

  • Node version: v8.10.0
  • Kafka-node version: ^2.6.1
  • Kafka version: 2.0.0

Most helpful comment

Can you try with version 3.0?

All 5 comments

Can you try with version 3.0?

@hyperlink I've just try to change the version in package.json manually and... It helps!
It's really fix the problem
Thank you very much! =)
Does it mean that 2.6.1 version is deprecated? I've installed it with

$ yarn add kafka-node

command

I'm glad that worked for you.

Does it mean that 2.6.1 version is deprecated?

We don't have bandwidth to support older releases.

I thought yarn just used npm's repository? Not familiar with it.

Yes, it's kind of wrapper for npm

Anyway problem is solved
Thank you once again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cheungwsj picture cheungwsj  路  5Comments

kameshwari-suresh picture kameshwari-suresh  路  3Comments

ashishnetworks picture ashishnetworks  路  4Comments

quorak picture quorak  路  5Comments

Sonivaibhav26 picture Sonivaibhav26  路  5Comments