Skip to content

Commit

Permalink
Fix max message size for gRPC call (#40)
Browse files Browse the repository at this point in the history
* feat(rpc.go): increase maxMessageSize to 200MB to handle larger data
refactor(rpc.go): rename nodeEndpoint to gRPCEndpoint for better clarity
feat(rpc.go): add grpc.WithDefaultCallOptions to set max receive and send message size, improving data handling capabilities
  • Loading branch information
Jossec101 authored Jul 27, 2023
1 parent d7e7558 commit cb71f05
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
"google.golang.org/grpc/credentials/insecure"
)

var maxMessageSize = 200 * 1024 * 1024 // 200MB

// Generates the gRPC lightning client∏
func CreateLightningClient(lndConnectParams lndconnect.LndConnectParams) (lnrpc.LightningClient, *grpc.ClientConn, error) {
creds, err := generateCredentials(lndConnectParams.Cert)
Expand Down Expand Up @@ -71,8 +73,11 @@ func CreateNodeGuardClient(nodeGuardEndpoint string) (nodeguard.NodeGuardService
}

// generates the gRPC connection based on the node endpoint and the credentials
func getConn(nodeEndpoint string, creds credentials.TransportCredentials) (*grpc.ClientConn, error) {
conn, err := grpc.Dial(nodeEndpoint, grpc.WithTransportCredentials(creds),
func getConn(gRPCEndpoint string, creds credentials.TransportCredentials) (*grpc.ClientConn, error) {
conn, err := grpc.Dial(gRPCEndpoint, grpc.WithTransportCredentials(creds),
grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(maxMessageSize),
grpc.MaxCallSendMsgSize(maxMessageSize)),
grpc.WithUnaryInterceptor(otelgrpc.UnaryClientInterceptor()),
grpc.WithStreamInterceptor(otelgrpc.StreamClientInterceptor()))

Expand Down

0 comments on commit cb71f05

Please sign in to comment.