Skip to content

Commit ca8f64e

Browse files
fix(spanner): Configure keepAlive time for gRPC TCP connections (#13216)
Default keep alive time is 120 seconds. If customer wants to override they can override it by passing the keepAlive configuration in the opts.
1 parent 9a4cb31 commit ca8f64e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

spanner/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
"google.golang.org/grpc/codes"
4545
"google.golang.org/grpc/credentials/insecure"
4646
"google.golang.org/grpc/encoding/gzip"
47+
"google.golang.org/grpc/keepalive"
4748
"google.golang.org/grpc/metadata"
4849
"google.golang.org/grpc/peer"
4950
"google.golang.org/grpc/status"
@@ -683,6 +684,7 @@ func allClientOpts(numChannels int, compression string, userOpts ...option.Clien
683684
option.WithUserAgent(fmt.Sprintf("spanner-go/v%s", internal.Version)),
684685
option.WithGRPCDialOption(grpc.WithChainUnaryInterceptor(addNativeMetricsInterceptor()...)),
685686
option.WithGRPCDialOption(grpc.WithChainStreamInterceptor(addStreamNativeMetricsInterceptor()...)),
687+
option.WithGRPCDialOption(grpc.WithKeepaliveParams(keepalive.ClientParameters{Time: 120 * time.Second})),
686688
}
687689
if enableDirectPathXds, _ := strconv.ParseBool(os.Getenv("GOOGLE_SPANNER_ENABLE_DIRECT_ACCESS")); enableDirectPathXds {
688690
clientDefaultOpts = append(clientDefaultOpts, internaloption.AllowNonDefaultServiceAccount(true))

0 commit comments

Comments
 (0)