fix keepalive bug (#484)

pull/463/head
longxboy 5 years ago committed by Tony
parent c18d7cc6ec
commit 8691205479
  1. 6
      pkg/net/rpc/warden/client.go
  2. 2
      pkg/net/rpc/warden/server.go

@ -27,6 +27,7 @@ import (
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/peer"
gstatus "google.golang.org/grpc/status"
@ -274,6 +275,11 @@ func (c *Client) dial(ctx context.Context, target string, opts ...grpc.DialOptio
if !c.conf.NonBlock {
dialOptions = append(dialOptions, grpc.WithBlock())
}
dialOptions = append(dialOptions, grpc.WithKeepaliveParams(keepalive.ClientParameters{
Time: time.Duration(c.conf.KeepAliveInterval),
Timeout: time.Duration(c.conf.KeepAliveTimeout),
PermitWithoutStream: !c.conf.KeepAliveWithoutStream,
}))
dialOptions = append(dialOptions, opts...)
// init default handler

@ -36,7 +36,7 @@ var (
Network: "tcp",
Addr: "0.0.0.0:9000",
Timeout: xtime.Duration(time.Second),
IdleTimeout: xtime.Duration(time.Second * 60),
IdleTimeout: xtime.Duration(time.Second * 180),
MaxLifeTime: xtime.Duration(time.Hour * 2),
ForceCloseWait: xtime.Duration(time.Second * 20),
KeepAliveInterval: xtime.Duration(time.Second * 60),

Loading…
Cancel
Save