2019-01-10 22:32
浏览 798


I have grpc server written in Go and I am trying to update receive and send message size to 20MB instead of the default 4MB with the following code

var s *grpc.Server
s = grpc.NewServer(grpc.MaxRecvMsgSize(1024*1024*20), grpc.MaxSendMsgSize(1024*1024*20))


But the above doesn't seem to be working as I still get an error when I tried to call from a client received message larger than max (5807570 vs. 4194304)" Not sure whats overriding the size

图片转代码服务由CSDN问答提供 功能建议

我用Go语言编写了grpc服务器,并且我尝试将接收和发送消息的大小更新为20MB,而不是默认值 具有以下代码的4MB

  var s * grpc.Server 
s = grpc.NewServer(grpc.MaxRecvMsgSize(1024 * 1024 * 20),grpc.MaxSendMsgSize(1024 * 1024)  * 20))

但上述方法似乎不起作用,因为当我仍然遇到错误时 尝试从客户端收到的大于最大长度的邮件(5807570与4194304)进行呼叫“ 不确定是什么覆盖了大小

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douming4359 2019-01-11 02:45

    I haven't had the chance to test this yet but have you tried adding the same options from the client stub? The same options can be attached as dial options:

    maxMsgSize := 1024*1024*20
    conn, err := grpc.Dial(address, grpc.WithDefaultCallOptions(grpc.MaxRecvMsgSize(maxMsgSize), grpc.MaxSendMsgSize(maxMsgSize)))
    if err != nil {
        // ...
    defer conn.close()
    client := pb.NewProductClient(conn)
    // ...

    I don't know anything about your use case but if your response data can be delivered piece wise then the streaming APIs might be useful.

    点赞 打赏 评论

相关推荐 更多相似问题