Kafka consumer receives nothing when there is data in the topic from kafka producer
Neo0165CA opened this issue · 5 comments
Hi there,
I am facing issue with kafka-node, Kafka consumer can not receive nothing when there is data in the topic from kafka producer but when we change the topic name then it can access the data, please check the below sample code and let me know where i am getting wrong
- Node version: 13.10.1
- Kafka-node version: 5.0.0
- Kafka version:
For specific cases also provide
- Number of Brokers: 1
- Number partitions for topic: 1 (0 by default)
var kafka = require("kafka-node");
var Consumer = kafka.Consumer,
client = new kafka.KafkaClient({kafkaHost: hostClient});
consumer = new Consumer(
client, [ {
topic: 'stock_prices12',
}],
{
autoCommit: true,
fetchMaxWaitMs: 100,
fetchMaxBytes: 1024 * 1024,
encoding: 'utf8',
fromOffset: false,
fromBeginning: false
},
options =
{
fromOffset: 'latest'
},
);
consumer.on('message', function (message) {
wss.broadcast(JSON.parse(message.value));
});
const wss = new SocketServer({ server });
wss.broadcast = function broadcast(data) {
wss.clients.forEach(function each(client) {
client.send(JSON.stringify(data));
});
};
Include output with Debug turned on
Thanks for your contribution!
Have you been able to fix this ? I am having the same exact issue. @Neo0165CA
Same problem here. It was working fine few days ago
Same issue, but only on AWS EKS.
While on local (kubernetes docker for windows), it works
Try groupId in options={}, I have set groupId on basis of environments (like Development, Production, QA)
If your consumer is connecting to the topic for the first time (if your consumer's groupId
is not yet registered), you will need to set fromOffset: 'earliest'
if you want to consume existing messages in the topic.