diff --git a/client/main.go b/client/main.go index acc3845..55112b6 100644 --- a/client/main.go +++ b/client/main.go @@ -28,13 +28,14 @@ func main() { continue } - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) // conn, err := grpc.Dial("127.0.0.1:9001", grpc.WithBlock(), grpc.WithInsecure()) conn, err := grpc.DialContext(ctx, fmt.Sprintf("%s:%d", node.Address, node.Port), grpc.WithBlock(), grpc.WithInsecure(), grpc.WithBalancerName("round_robin")) if err != nil { + fmt.Printf("%v\n", err) cancel() } - defer conn.Close() + c := pb.NewHelloClient(conn) resp, err := c.Say(ctx, &pb.SayRequest{Name: "jiale", Day: "2008-08-08"}) if err != nil { @@ -45,6 +46,6 @@ func main() { log.WithFields(log.Fields{ "func": "main", }).Infof("%s", resp.Reply) - + conn.Close() } }