|
|
|
@ -29,6 +29,10 @@ import ( |
|
|
|
|
|
|
|
const ( |
|
|
|
Max_Message_Size = 1 << 30 // 1 GB
|
|
|
|
|
|
|
|
// gRPC keepalive settings - must be consistent between client and server
|
|
|
|
GrpcKeepAliveTime = 60 * time.Second // ping interval when no activity
|
|
|
|
GrpcKeepAliveTimeout = 20 * time.Second // ping timeout
|
|
|
|
) |
|
|
|
|
|
|
|
var ( |
|
|
|
@ -52,12 +56,12 @@ func NewGrpcServer(opts ...grpc.ServerOption) *grpc.Server { |
|
|
|
var options []grpc.ServerOption |
|
|
|
options = append(options, |
|
|
|
grpc.KeepaliveParams(keepalive.ServerParameters{ |
|
|
|
Time: 60 * time.Second, // wait time before ping if no activity (match client)
|
|
|
|
Timeout: 20 * time.Second, // ping timeout
|
|
|
|
Time: GrpcKeepAliveTime, // wait time before ping if no activity
|
|
|
|
Timeout: GrpcKeepAliveTimeout, // ping timeout
|
|
|
|
// MaxConnectionAge: 10 * time.Hour,
|
|
|
|
}), |
|
|
|
grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ |
|
|
|
MinTime: 60 * time.Second, // min time a client should wait before sending a ping (match client)
|
|
|
|
MinTime: GrpcKeepAliveTime, // min time a client should wait before sending a ping
|
|
|
|
PermitWithoutStream: true, |
|
|
|
}), |
|
|
|
grpc.MaxRecvMsgSize(Max_Message_Size), |
|
|
|
@ -89,8 +93,8 @@ func GrpcDial(ctx context.Context, address string, waitForReady bool, opts ...gr |
|
|
|
grpc.WaitForReady(waitForReady), |
|
|
|
), |
|
|
|
grpc.WithKeepaliveParams(keepalive.ClientParameters{ |
|
|
|
Time: 60 * time.Second, // client ping server if no activity for this long
|
|
|
|
Timeout: 20 * time.Second, |
|
|
|
Time: GrpcKeepAliveTime, // client ping server if no activity for this long
|
|
|
|
Timeout: GrpcKeepAliveTimeout, // ping timeout
|
|
|
|
PermitWithoutStream: true, |
|
|
|
})) |
|
|
|
for _, opt := range opts { |
|
|
|
|