Skip to content

Commit

Permalink
grpclb: enable keepalive (#2918)
Browse files Browse the repository at this point in the history
So grpclb client will reconnect when the connection is down (e.g. proxy
drops the server side connection but keeps the client side).
  • Loading branch information
menghanl committed Jul 22, 2019
1 parent c654cab commit a975db9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions balancer/grpclb/grpclb_remote_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/internal"
"google.golang.org/grpc/internal/channelz"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/resolver"
)
Expand Down Expand Up @@ -349,6 +350,13 @@ func (lb *lbBalancer) dialRemoteLB(remoteLBName string) {
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
// generated when init grpclb. The target scheme here is not important.
//
Expand Down

0 comments on commit a975db9

Please sign in to comment.