Golang grpc message too large? Teach you how to solve it quickly!

藏色散人
Release: 2022-12-07 15:45:42
forward
5763 people have browsed it

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!

Golang grpc message too large? Teach you how to solve it quickly!

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)
Copy after login

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))))),         // 设置接收消息大小
    }
}
Copy after login

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!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template