Skip to content

Commit

Permalink
clientv3: ensure 'DialKeepAliveTime' respects server policy
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <[email protected]>
  • Loading branch information
gyuho committed Jul 20, 2017
1 parent 1d31a0c commit 82ccb21
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clientv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"sync"
"time"

kp "github.com/coreos/etcd/etcdserver/api/v3rpc/keepalive"
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"

"golang.org/x/net/context"
Expand Down Expand Up @@ -217,6 +218,10 @@ func (c *Client) dialSetupOpts(endpoint string, dopts ...grpc.DialOption) (opts
opts = []grpc.DialOption{grpc.WithTimeout(c.cfg.DialTimeout)}
}
if c.cfg.DialKeepAliveTime > 0 {
// prevent incompatible settings that can lead to connection close from server-side
if c.cfg.DialKeepAliveTime < kp.ServerPolicy.MinTime {
panic(fmt.Errorf("client keepalive can send too_many_pings (expects >%v, got %v)", kp.ServerPolicy.MinTime, c.cfg.DialKeepAliveTime))
}
params := keepalive.ClientParameters{
Time: c.cfg.DialKeepAliveTime,
}
Expand Down

0 comments on commit 82ccb21

Please sign in to comment.