Skip to content

Commit f09ef2a

Browse files
authored
test: fix TAV=kafkajs tests (#4773)
Kafka TAV tests (which run in docker) had been failing with: KafkaJSConnectionError: Connection error: connect ECONNREFUSED 127.0.0.1:9094 even though the client was configured to connect to `kafka:9094`. Where did the "127.0.0.1" (or "localhost") come from? The answer is from the Kafka broker metadata, which comes from the `KAFKA_ADVERTISED_LISTENERS` config. Explanation at https://www.confluent.io/blog/kafka-listeners-explained/ TIL: A Kafka client's initial options include broker host/port details. That is used for the initial (seed) connection to get broker metadata. The metadata includes connection details, which can depend the topic(s).
1 parent 9a1aded commit f09ef2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

.ci/docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ services:
155155
- "KAFKA_NODE_ID=1"
156156
- "KAFKA_PROCESS_ROLES=broker,controller"
157157
- "KAFKA_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094"
158-
- "KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092,EXTERNAL://localhost:9094"
158+
- "KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092,EXTERNAL://kafka:9094"
159159
- "KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,EXTERNAL:PLAINTEXT"
160160
- "KAFKA_CONTROLLER_QUORUM_VOTERS=1@localhost:9093"
161161
- "KAFKA_CONTROLLER_LISTENER_NAMES=CONTROLLER"

0 commit comments

Comments
 (0)