Yashy
Yashy

Reputation: 191

What is the maximum number of bytes that can be specified in grpc.MaxCallSendMsgSize?

The problem:

I am getting this error while receiving message in grpc:

grpc: received message larger than max (11509754 vs. 4194304)

What I tried:

I gave the option to increase the size of the message to be sent but it still gave the same error which means this setting of maximum size didn't work:

maxSizeOption := grpc.MaxCallSendMsgSize(50 * 1024 * 1024)
if _, err := grpcClient.Foo(request, maxSizeOption); err != nil {
    return err
}

Comments:

I don't understand why the error message shows 4194304(=4MB). Is there a maximum number of bytes that can be set for grpc.MaxCallSendMsgSize?

To add, when I passed 10MB to MaxCallSendMsgSize, I got the error:

trying to send message larger than max (11509754 vs. 10485760)

This was expected.

Addendum:

When I passed 10MB to MaxCallSendMsgSize and MaxCallRecvMsgSize, I got the same error:

size := 50* 1024 * 1024
maxSendSizeOption := grpc.MaxCallSendMsgSize(size)
maxRecvSizeOption := grpc.MaxCallRecvMsgSize(size)
if _, err := grpcClient.Foo(request,maxSendSizeOption,maxRecvSizeOption); err != nil {
   return err
}

error:

grpc: received message larger than max (11509754 vs. 4194304)

Upvotes: 1

Views: 3794

Answers (1)

Yashy
Yashy

Reputation: 191

I set those options server too, and it worked. Thanks JimB and Зелёный!

// server side
size := 1024 * 1024 * 50
server := grpc.NewServer(
    grpc.MaxSendMsgSize(size),
    grpc.MaxRecvMsgSize(size),
)

Upvotes: 3

Related Questions