Simple example using Go timing out after 20 seconds
Closed this issue · 2 comments
hermanschaaf commented
Hi, I am trying to write a simple GRPC consumer in Go. For a start, I thought I'd try and list the available topics with ListTopics
. I was able to connect to port 19092 via curl and consume messages via that route, so I think kafka-pixy is set up correctly. But using Go and gRPC I get timeouts.
Here is the code I'm running:
package main
import (
pb "github.com/mailgun/kafka-pixy/gen/golang"
"google.golang.org/grpc"
"time"
"context"
"log"
)
func main() {
serverAddr := "127.0.0.1:19091"
conn, err := grpc.Dial(serverAddr, grpc.WithInsecure())
if err != nil {
panic(err)
}
defer conn.Close()
client := pb.NewKafkaPixyClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
tr := pb.ListTopicRq{}
r, err := client.ListTopics(ctx, &tr)
if err != nil {
panic(err)
}
log.Println(r)
}
Unfortunately, it fails with:
panic: rpc error: code = DeadlineExceeded desc = context deadline exceeded
goroutine 1 [running]:
main.main()
/Users/hermanschaaf/hermanschaaf/kafka-read-proxy/main.go:26 +0x279
Process finished with exit code 2
Does anyone know what I might be doing wrong here?
horkhe commented
I hate to say it, but it works for me. Are you following the steps outlined here? If it still does not work for you please provide kafka-pixy logs.
horkhe commented
I am closing this as not reproducible. Feel free to reopen if you have more information.