From 80cf99db1b4ba9cb74b68523129d786b7ed85da3 Mon Sep 17 00:00:00 2001 From: chenwanli Date: Fri, 11 Jan 2019 18:23:31 +0800 Subject: [PATCH] Set rpc dial timeout to 5s --- weed/server/volume_grpc_client_to_master.go | 2 +- weed/util/grpc_client_server.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/weed/server/volume_grpc_client_to_master.go b/weed/server/volume_grpc_client_to_master.go index 7493f1460..fcbcfd4d4 100644 --- a/weed/server/volume_grpc_client_to_master.go +++ b/weed/server/volume_grpc_client_to_master.go @@ -40,7 +40,7 @@ func (vs *VolumeServer) doHeartbeat(masterNode string, sleepInterval time.Durati grpcConection, err := util.GrpcDial(masterNode) if err != nil { - return "", fmt.Errorf("fail to dial: %v", err) + return "", fmt.Errorf("fail to dial %s : %v", masterNode, err) } defer grpcConection.Close() diff --git a/weed/util/grpc_client_server.go b/weed/util/grpc_client_server.go index 18d5c02c9..d487e8bb4 100644 --- a/weed/util/grpc_client_server.go +++ b/weed/util/grpc_client_server.go @@ -25,7 +25,8 @@ func NewGrpcServer() *grpc.Server { } func GrpcDial(address string, opts ...grpc.DialOption) (*grpc.ClientConn, error) { - + opts = append(opts, grpc.WithBlock()) + opts = append(opts, grpc.WithTimeout(time.Duration(5*time.Second))) opts = append(opts, grpc.WithInsecure()) opts = append(opts, grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: 30 * time.Second, // client ping server if no activity for this long