0

我已经根据此处的说明在本地开发机器上安装了 Kafka: https ://kafka.apache.org/documentation/#quickstart

如上面链接中所述,我能够在运行 .sh 文件时生成和使用消息。

但是,当尝试使用 KafkaJS 从 nodejs 应用程序连接到 Kafka 时,Kafka 服务器中会记录以下错误:

[2020-05-15 09:07:41,210] WARN [SocketServer brokerId=0] Unexpected error from /127.0.0.1; closing connection (org.apache.kafka.common.network.Selector)
org.apache.kafka.common.network.InvalidReceiveException: Invalid receive (size = 369295617 larger than 104857600)
    at org.apache.kafka.common.network.NetworkReceive.readFrom(NetworkReceive.java:105)
    at org.apache.kafka.common.network.KafkaChannel.receive(KafkaChannel.java:448)
    at org.apache.kafka.common.network.KafkaChannel.read(KafkaChannel.java:398)
    at org.apache.kafka.common.network.Selector.attemptRead(Selector.java:678)
    at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:580)
    at org.apache.kafka.common.network.Selector.poll(Selector.java:485)
    at kafka.network.Processor.poll(SocketServer.scala:861)
    at kafka.network.Processor.run(SocketServer.scala:760)
    at java.lang.Thread.run(Thread.java:748)

生产者代码如下:

const kafka = new Kafka({
    brokers: ['localhost:9092'],
    ssl: { rejectUnauthorized: false }
})

const producer = kafka.producer();

await producer.connect()

任何想法为什么它不能从 Nodejs 代码工作,但在运行 .sh 文件时工作?

4

0 回答 0