mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 13:26:07 +00:00
peerstream: set keepalive enforcement to 15s (#13796)
The client is set to send keepalive pings every 30s. The server keepalive enforcement must be set to a number less than that, otherwise it will disconnect clients for sending pings too often. MinTime governs the minimum amount of time between pings.
This commit is contained in:
parent
7c0daeade8
commit
e8d965e56f
@ -5,6 +5,8 @@ import (
|
|||||||
recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
|
recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
|
"google.golang.org/grpc/keepalive"
|
||||||
|
"time"
|
||||||
|
|
||||||
agentmiddleware "github.com/hashicorp/consul/agent/grpc-middleware"
|
agentmiddleware "github.com/hashicorp/consul/agent/grpc-middleware"
|
||||||
"github.com/hashicorp/consul/tlsutil"
|
"github.com/hashicorp/consul/tlsutil"
|
||||||
@ -25,6 +27,12 @@ func NewServer(logger agentmiddleware.Logger, tls *tlsutil.Configurator) *grpc.S
|
|||||||
// Add middlware interceptors to recover in case of panics.
|
// Add middlware interceptors to recover in case of panics.
|
||||||
recovery.StreamServerInterceptor(recoveryOpts...),
|
recovery.StreamServerInterceptor(recoveryOpts...),
|
||||||
),
|
),
|
||||||
|
grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
|
||||||
|
// This must be less than the keealive.ClientParameters Time setting, otherwise
|
||||||
|
// the server will disconnect the client for sending too many keepalive pings.
|
||||||
|
// Currently the client param is set to 30s.
|
||||||
|
MinTime: 15 * time.Second,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
if tls != nil && tls.GRPCTLSConfigured() {
|
if tls != nil && tls.GRPCTLSConfigured() {
|
||||||
creds := credentials.NewTLS(tls.IncomingGRPCConfig())
|
creds := credentials.NewTLS(tls.IncomingGRPCConfig())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user