Set rpc dial timeout to 5s

This commit is contained in:
chenwanli
2019-01-11 18:23:31 +08:00
parent 8613e4f558
commit 80cf99db1b
2 changed files with 3 additions and 2 deletions

View File

@@ -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