Skip to content

Commit

Permalink
🐛 increase message size for grpc
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>
  • Loading branch information
pranavgaikwad committed Jul 25, 2024
1 parent a24f7ea commit 6821427
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions provider/grpc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ func (g *grpcProvider) Stop() {
}

func start(ctx context.Context, config provider.Config) (*grpc.ClientConn, io.ReadCloser, error) {
// default is 4M, we use 8M
maxMessageSize := 1024 * 1024 * 8
// Here the Provider will start the GRPC Server if a binary is set.
if config.BinaryPath != "" {
port, err := freeport.GetFreePort()
Expand Down Expand Up @@ -259,15 +261,19 @@ func start(ctx context.Context, config provider.Config) (*grpc.ClientConn, io.Re
if err != nil {
return nil, nil, err
}
conn, err := grpc.Dial(fmt.Sprintf("localhost:%v", port), grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.Dial(fmt.Sprintf("localhost:%v", port),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMessageSize)),
grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
return conn, out, nil
}
if config.Address != "" {
if config.CertPath == "" {
conn, err := grpc.Dial(fmt.Sprintf(config.Address), grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.Dial(fmt.Sprintf(config.Address),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMessageSize)),
grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
Expand All @@ -278,7 +284,9 @@ func start(ctx context.Context, config provider.Config) (*grpc.ClientConn, io.Re
return nil, nil, err
}
if config.JWTToken == "" {
conn, err := grpc.Dial(fmt.Sprintf(config.Address), grpc.WithTransportCredentials(creds))
conn, err := grpc.Dial(fmt.Sprintf(config.Address),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMessageSize)),
grpc.WithTransportCredentials(creds))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
Expand All @@ -288,7 +296,9 @@ func start(ctx context.Context, config provider.Config) (*grpc.ClientConn, io.Re
i := &jwtTokeInterceptor{
Token: config.JWTToken,
}
conn, err := grpc.Dial(fmt.Sprintf(config.Address), grpc.WithTransportCredentials(creds), grpc.WithUnaryInterceptor(i.unaryInterceptor))
conn, err := grpc.Dial(fmt.Sprintf(config.Address),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMessageSize)),
grpc.WithTransportCredentials(creds), grpc.WithUnaryInterceptor(i.unaryInterceptor))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion provider/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (s *server) Start(ctx context.Context) error {
gs = grpc.NewServer(grpc.Creds(creds))
}
} else if s.CertPath == "" && s.KeyPath == "" {
gs = grpc.NewServer()
gs = grpc.NewServer(grpc.MaxRecvMsgSize(1024*1024*24), grpc.MaxSendMsgSize(1024*1024*24))
} else {
return fmt.Errorf("cert: %v, and key: %v are invalid", s.CertPath, s.KeyPath)
}
Expand Down

0 comments on commit 6821427

Please sign in to comment.