Skip to content

Commit

Permalink
RSDK-8215 - Decrease amount of GOAWAY errors (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheukt authored Jul 16, 2024
1 parent 1761ab8 commit 876de04
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
11 changes: 9 additions & 2 deletions rpc/const.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package rpc

// MaxMessageSize is the maximum size a gRPC message can be.
var MaxMessageSize = 1 << 25
import "time"

var (
// MaxMessageSize is the maximum size a gRPC message can be.
MaxMessageSize = 1 << 25

// keepAliveTime is how often to establish Keepalive pings/expectations.
keepAliveTime = 10 * time.Second
)
3 changes: 1 addition & 2 deletions rpc/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"hash/fnv"
"strings"
"sync"
"time"

"github.com/edaniels/golog"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
Expand Down Expand Up @@ -244,7 +243,7 @@ func dialDirectGRPC(ctx context.Context, address string, dOpts dialOptions, logg
grpc.WithBlock(),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(MaxMessageSize)),
grpc.WithKeepaliveParams(keepalive.ClientParameters{
Time: 15 * time.Second, // a little extra buffer to try to avoid ENHANCE_YOUR_CALM
Time: keepAliveTime * 2, // a little extra buffer to try to avoid ENHANCE_YOUR_CALM
PermitWithoutStream: true,
}),
}
Expand Down
8 changes: 7 additions & 1 deletion rpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/reflection"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -179,7 +180,12 @@ func NewServer(logger golog.Logger, opts ...ServerOption) (Server, error) {
return nil, err
}

var serverOpts []grpc.ServerOption
serverOpts := []grpc.ServerOption{
grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
MinTime: keepAliveTime / 2, // a little extra buffer to try to avoid ENHANCE_YOUR_CALM
PermitWithoutStream: true,
}),
}

var firstSeenTLSCert *tls.Certificate
if sOpts.tlsConfig != nil {
Expand Down

0 comments on commit 876de04

Please sign in to comment.