I am using github.com/Shopify/sarama package to interact with Kafka. In my current approach I could connect to the broker and get all topic names without a problem (Consumer Code below).
However, when I try to delete some topic using the admin client (Admin Code below) I receive the "dial tcp: lookup ip-x-x-xx.ec2.internal: no such host" error.
I am out of ideas why I do receive this error. I would much appreciate any hints or possible solutions.
Consumer
config := sarama.NewConfig()
config.Consumer.Return.Errors = true
//get broker
cluster, err := sarama.NewConsumer("localhost:9092", config)
if err != nil {
panic(err)
}
defer func() {
if err := cluster.Close(); err != nil {
panic(err)
}
}()
//get all topic from cluster
topics, _ := cluster.Topics()
Admin
config := sarama.NewConfig()
config.Consumer.Return.Errors = true
config.Version = sarama.V2_4_0_0
//admin broker
admin, err := sarama.NewClusterAdmin("localhost:9092", config)
if err != nil {
panic(err)
}
defer func() {
if err := admin.Close(); err != nil {
panic(err)
}
}()
topic := []string{"test-topic"}
output := admin.DeleteTopic(topic)
if output == nil {
fmt.Printf(" delete - %s\n", topic[0])
} else {
fmt.Println(output)
}
Note I am connecting over bastion instance into a remote by forwarding ssh ports.
Update
after setting sarama.Logger = log.New(os.Stdout, "[sarama] ", log.LstdFlags)
I get the following:
[sarama] 2020/03/25 02:08:03 Initializing new client
[sarama] 2020/03/25 02:08:03 client/metadata fetching metadata for all topics from broker localhost:9092
[sarama] 2020/03/25 02:08:04 Connected to broker at localhost:9092 (unregistered)
[sarama] 2020/03/25 02:08:04 client/brokers registered new broker #1001 at ip-x-x-x-1.ec2.internal:9092
[sarama] 2020/03/25 02:08:04 client/brokers registered new broker #1003 at ip-x-x-x-2.ec2.internal:9092
[sarama] 2020/03/25 02:08:04 client/brokers registered new broker #1002 at ip-x-x-x-3.ec2.internal:9092
[sarama] 2020/03/25 02:08:04 Successfully initialized new client
[sarama] 2020/03/25 02:08:04 Failed to connect to broker ip-x-x-x-3.ec2.internal:9092: dial tcp: lookup ip-x-x-x-3.ec2.internal: no such host`
Update 2
my kafka server.properties:
advertised.listeners=INTERNAL://ip-x-x-x-1.ec2.internal:9091,EXTERNAL_INSECURE://ip-x-x-x-1.ec2.internal:9092
listeners=INTERNAL://:9091,EXTERNAL_INSECURE://:9092
listener.security.protocol.map=INTERNAL:SSL,EXTERNAL_INSECURE:PLAINTEXT