@@ -79,23 +79,25 @@ func dial(params dialParameters) (*grpc.ClientConn, error) {
79
79
}
80
80
cp .Backoff .BaseDelay = retryPollOperationInitialInterval
81
81
cp .Backoff .MaxDelay = retryPollOperationMaxInterval
82
-
83
- // gRPC utilizes keep alive mechanism to detect dead connections in case if server didn't close them
84
- // gracefully. Client would ping the server periodically and expect replies withing the specified timeout.
85
- // Learn more by reading https://github.com/grpc/grpc/blob/master/doc/keepalive.md
86
- var kap = keepalive.ClientParameters {
87
- Time : 30 * time .Second ,
88
- Timeout : 15 * time .Second ,
89
- PermitWithoutStream : true ,
90
- }
91
-
92
- return grpc .Dial (params .HostPort ,
82
+ opts := []grpc.DialOption {
93
83
grpcSecurityOptions ,
94
84
grpc .WithChainUnaryInterceptor (params .RequiredInterceptors ... ),
95
85
grpc .WithDefaultServiceConfig (params .DefaultServiceConfig ),
96
86
grpc .WithConnectParams (cp ),
97
- grpc .WithKeepaliveParams (kap ),
98
- )
87
+ }
88
+
89
+ if params .UserConnectionOptions .EnableKeepAliveCheck {
90
+ // gRPC utilizes keep alive mechanism to detect dead connections in case if server didn't close them
91
+ // gracefully. Client would ping the server periodically and expect replies withing the specified timeout.
92
+ // Learn more by reading https://github.com/grpc/grpc/blob/master/doc/keepalive.md
93
+ var kap = keepalive.ClientParameters {
94
+ Time : params .UserConnectionOptions .KeepAliveTime ,
95
+ Timeout : params .UserConnectionOptions .KeepAliveTimeout ,
96
+ PermitWithoutStream : params .UserConnectionOptions .KeepAlivePermitWithoutStream ,
97
+ }
98
+ opts = append (opts , grpc .WithKeepaliveParams (kap ))
99
+ }
100
+ return grpc .Dial (params .HostPort , opts ... )
99
101
}
100
102
101
103
func requiredInterceptors (metricScope tally.Scope , headersProvider HeadersProvider ) []grpc.UnaryClientInterceptor {
0 commit comments