i have this producer
const { Kafka } = require("kafkajs");
const kafka = new Kafka({
clientId: "app",
brokers: ["localhost:29092"],
});
async function sendMessageOnProducer() {
const producer = kafka.producer();
await producer.connect();
await producer.send({
topic: "test",
messages: [
{
value: "hello",
},
],
});
producer.disconnect();
}
sendMessageOnProducer();
and i have this docker compose
version: '2'
services:
zookeeper:
container_name: cluster
image: confluentinc/cp-zookeeper:latest
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
kafka:
container_name: kafka
image: confluentinc/cp-kafka:latest
depends_on:
- zookeeper
ports:
- 29092:29092
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
but when i run my producer i have this error
{"level":"ERROR","timestamp":"2023-05-30T14:58:26.187Z","logger":"kafkajs","message":"[BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection error: connect ECONNREFUSED ::1:29092","retryCount":5,"retryTime":6966}
i'm trying to send a payload to my kafka