grpclb: enable keepalive (#2918)

So grpclb client will reconnect when the connection is down (e.g. proxy
drops the server side connection but keeps the client side).
This commit is contained in:
Menghan Li
2019-07-22 12:44:59 -07:00
committed by GitHub
parent c654cab129
commit a975db9349

View File

@ -34,6 +34,7 @@ import (
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
"google.golang.org/grpc/internal" "google.golang.org/grpc/internal"
"google.golang.org/grpc/internal/channelz" "google.golang.org/grpc/internal/channelz"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"google.golang.org/grpc/resolver" "google.golang.org/grpc/resolver"
) )
@ -349,6 +350,13 @@ func (lb *lbBalancer) dialRemoteLB(remoteLBName string) {
dopts = append(dopts, grpc.WithChannelzParentID(lb.opt.ChannelzParentID)) dopts = append(dopts, grpc.WithChannelzParentID(lb.opt.ChannelzParentID))
} }
// Enable Keepalive for grpclb client.
dopts = append(dopts, grpc.WithKeepaliveParams(keepalive.ClientParameters{
Time: 20 * time.Second,
Timeout: 10 * time.Second,
PermitWithoutStream: true,
}))
// DialContext using manualResolver.Scheme, which is a random scheme // DialContext using manualResolver.Scheme, which is a random scheme
// generated when init grpclb. The target scheme here is not important. // generated when init grpclb. The target scheme here is not important.
// //