Neo4j and Kafka containers seem to be unable to communicate with each other #6223
-
EDIT: Hardcoded connection string 'kafka:9092' with an explicit network alias of 'kafka' on the KafkaContainer ended up being the answer. Slight variations on the format fail and it is not returned from any internal methods in a way which can be used for connection strings. Hello I have been working on converting some our existing neo4j plugin tests from the legacy neo4j test-harness over to testcontainers. For most uses cases this is working as expected, but in cases where we try to connect to testcontainers kafka from our neo4j testcontainer we're seeing some unexpected results when using docker networking and the neo4j streams kafka plugin. General overview :
Both containers start as expected, but no matter the value I put for Typical error message:
The address here is notable... for most formatted It's not clear to my why these values are being converted (or which piece of code is responsible for this). With our docker compose configurations we can simply use 'kafka.bootstrap.servers={ALIAS}:{PORT}'. I've tried assigned explicit aliases and using hardcoded configuraions, mounting configuration files directly, but nearly every solution results in the 'localhost' values being used at runtime. Is there something I'm misconfiguring here, or is there a potential issue with trying to get these two containers to interact in this way through testcontainers? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
@jameswylyreasint can you share a minimal sample reproducer, please? I have @Test
void test() {
Network network = Network.newNetwork();
try (KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:6.2.1"))
.withNetwork(network)
.withNetworkAliases("kafka");
Neo4jContainer<?> neo4j = new Neo4jContainer<>(DockerImageName.parse("neo4j:4.4.11-enterprise"))
.withNetwork(network)
.withEnv("NEO4J_kafka_bootstrap_servers", "kafka:9093")
.withEnterpriseEdition()
.withLabsPlugins(Neo4jLabsPlugin.STREAMS)
.dependsOn(kafka)) {
Startables.deepStart(kafka, neo4j).join();
}
} and I'm not able to see the WARN. I follow this but looks like there are more containers involved, want to make sure I'm not missing something from your report. |
Beta Was this translation helpful? Give feedback.
@jameswylyreasint can you share a minimal sample reproducer, please? I have