I have a go project with confluent Kafka and I want to change it's initial connection timeout. If the kafka is not available on the first try I want to retry connecting to it every few seconds and give up retrying after 10 min.
By default it is repeatedly trying to connect to Kafka without break, I am getting the following log over again: [thrd:localhost:9092/bootstrap]: localhost:9092/bootstrap: Connect to ipv6#[::1]:9092 failed: Connection refused (after 1ms in state CONNECT)
(sometimes lightly different eg ipv4 instead of ipv6 and 0ms or 2ms instead of 1ms)
I've tried the following configurations but none of them seems to work
conf := kafka.ConfigMap{
"bootstrap.servers": fmt.Sprintf("%s:%d", kafkaHost, kafkaPort),
"group.id": "billing",
"auto.offset.reset": "earliest",
"go.logs.channel.enable": true,
"heartbeat.interval.ms": 10000,
"session.timeout.ms": 10000,
"connections.max.idle.ms": 10000,
"max.poll.interval.ms": 10000,
"socket.connection.setup.timeout.ms": 10000,
"auto.commit.interval.ms": 10000,
"metadata.max.age.ms": 100000,
"reconnect.backoff.max.ms": 100000,
"reconnect.backoff.ms": 10000,
}
I am able to connect to Kafka normally when it is running in a docker compose. Right now I only want to handle the case when it's down.
bootstrap.servers
, but in my experience, there isn't a wait for give up retrying connection, but yourreconnect.backoff.max.ms
is currently set to 100 seconds, not 10 minutes – Jugurtha.Consumer.Close()
. – Paraprofessional