英文:
What is the maximum number of bytes that can be specified in grpc.MaxCallSendMsgSize?
问题
问题:
在使用grpc接收消息时,我遇到了以下错误:
grpc: received message larger than max (11509754 vs. 4194304)
我尝试过的方法:
我尝试增加要发送的消息的大小,但仍然出现相同的错误,这意味着最大大小的设置没有起作用:
maxSizeOption := grpc.MaxCallSendMsgSize(50 * 1024 * 1024)
if _, err := grpcClient.Foo(request, maxSizeOption); err != nil {
return err
}
评论:
我不明白为什么错误消息显示为4194304(=4MB)。
grpc.MaxCallSendMsgSize是否有最大字节数的限制?
此外,当我将10MB传递给MaxCallSendMsgSize时,我得到了以下错误:
trying to send message larger than max (11509754 vs. 10485760)
这是预期的。
补充说明:
当我将10MB传递给MaxCallSendMsgSize和MaxCallRecvMsgSize时,我得到了相同的错误:
size := 50* 1024 * 1024
maxSendSizeOption := grpc.MaxCallSendMsgSize(size)
maxRecvSizeOption := grpc.MaxCallRecvMsgSize(size)
if _, err := grpcClient.Foo(request,maxSendSizeOption,maxRecvSizeOption); err != nil {
return err
}
错误信息:
grpc: received message larger than max (11509754 vs. 4194304)
英文:
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)
答案1
得分: 2
我也设置了这些选项,并且它起作用了。
谢谢JimB和Зелёный!
// 服务器端
size := 1024 * 1024 * 50
server := grpc.NewServer(
grpc.MaxSendMsgSize(size),
grpc.MaxRecvMsgSize(size),
)
英文:
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),
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论