msg rpc max

This commit is contained in:
wangchuxiao 2022-11-30 16:13:03 +08:00
parent 271934ef4b
commit 19da03dfa4
2 changed files with 14 additions and 6 deletions

View File

@ -15,10 +15,12 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/gob" "encoding/gob"
"github.com/golang/protobuf/proto"
"github.com/gorilla/websocket"
"runtime" "runtime"
"strings" "strings"
"github.com/golang/protobuf/proto"
"github.com/gorilla/websocket"
"google.golang.org/grpc"
) )
func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) { func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
@ -150,7 +152,8 @@ func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
return return
} }
msgClient := pbChat.NewMsgClient(grpcConn) msgClient := pbChat.NewMsgClient(grpcConn)
reply, err := msgClient.PullMessageBySeqList(context.Background(), &rpcReq) maxSizeOption := grpc.MaxCallRecvMsgSize(1024 * 1024 * 20)
reply, err := msgClient.PullMessageBySeqList(context.Background(), &rpcReq, maxSizeOption)
if err != nil { if err != nil {
log.NewError(rpcReq.OperationID, "pullMsgBySeqListReq err", err.Error()) log.NewError(rpcReq.OperationID, "pullMsgBySeqListReq err", err.Error())
nReply.ErrCode = 200 nReply.ErrCode = 200

View File

@ -10,11 +10,12 @@ import (
"Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/grpc-etcdv3/getcdv3"
"Open_IM/pkg/proto/msg" "Open_IM/pkg/proto/msg"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"github.com/golang/protobuf/proto"
"net" "net"
"strconv" "strconv"
"strings" "strings"
"github.com/golang/protobuf/proto"
grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus" grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"google.golang.org/grpc" "google.golang.org/grpc"
@ -94,8 +95,12 @@ func (rpc *rpcChat) Run() {
panic("listening err:" + err.Error() + rpc.rpcRegisterName) panic("listening err:" + err.Error() + rpc.rpcRegisterName)
} }
log.Info("", "listen network success, address ", address) log.Info("", "listen network success, address ", address)
recvSize := 1024 * 1024 * 30
var grpcOpts []grpc.ServerOption sendSize := 1024 * 1024 * 30
var grpcOpts = []grpc.ServerOption{
grpc.MaxRecvMsgSize(recvSize),
grpc.MaxSendMsgSize(sendSize),
}
if config.Config.Prometheus.Enable { if config.Config.Prometheus.Enable {
promePkg.NewGrpcRequestCounter() promePkg.NewGrpcRequestCounter()
promePkg.NewGrpcRequestFailedCounter() promePkg.NewGrpcRequestFailedCounter()