Browse Source

Set rpc dial timeout to 5s

pull/831/head
chenwanli 6 years ago
parent
commit
80cf99db1b
  1. 2
      weed/server/volume_grpc_client_to_master.go
  2. 3
      weed/util/grpc_client_server.go

2
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()

3
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

Loading…
Cancel
Save