Home > Article > Backend Development > Golang grpc message too large? Teach you how to solve it quickly!
This article is introduced by the golang tutorial column to introduce to you how to solve the problem of excessive grpc messages? Hope it helps those in need!
Solution to the problem of too large grpc messages
Today the front-end reported a problem, the interface reported an error, and then I went to the server and saw the error log The prompt is as follows:
code = ResourceExhausted desc = grpc: received message larger than max (4998958 vs. 4194304)
means:
The received message is greater than the specified value. This value should be the default, so a custom value needs to be set.
Needs to be in rpc client Set custom size on end
func NewServiceContext(c config.Config) *ServiceContext { return &ServiceContext{ Config: c, // 此处是rpc client端,用于调用server端 ConvertRpc: convert.NewConvert(zrpc.MustNewClient(c.ConvertRpcConf, zrpc.WithDialOption(grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024 * 1024 * 10))))), // 设置接收消息大小 } }
The above is the detailed content of Golang grpc message too large? Teach you how to solve it quickly!. For more information, please follow other related articles on the PHP Chinese website!