Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 increase message size for grpc #673

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions provider/grpc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,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(provider.MAX_MESSAGE_SIZE)),
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(provider.MAX_MESSAGE_SIZE)),
grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
Expand All @@ -278,7 +282,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(provider.MAX_MESSAGE_SIZE)),
grpc.WithTransportCredentials(creds))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
Expand All @@ -288,7 +294,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(provider.MAX_MESSAGE_SIZE)),
grpc.WithTransportCredentials(creds), grpc.WithUnaryInterceptor(i.unaryInterceptor))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
Expand Down
3 changes: 2 additions & 1 deletion provider/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

const (
JWT_SECRET_ENV_VAR = "JWT_SECRET"
MAX_MESSAGE_SIZE = 1024 * 1024 * 8
)

type Server interface {
Expand Down Expand Up @@ -116,7 +117,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(MAX_MESSAGE_SIZE), grpc.MaxSendMsgSize(MAX_MESSAGE_SIZE))
} else {
return fmt.Errorf("cert: %v, and key: %v are invalid", s.CertPath, s.KeyPath)
}
Expand Down
Loading