Closed adu202309 closed 12 months ago
func (c Client) RefreshConfig(ctx context.Context, args RefreshConfigReq) (reply *Resp, err error) { err = c.xclient.Call(ctx, "RefreshConfig", args, reply) fmt.Println("$$$$$$$$$$$$$$$$$: ", reply) return reply, err }
这样也一样拿到的是一个空nil
贴全一些信息
错误日志 + Resp数据结构
服务端代码: func (s ForwardImpl) BroadcastMsgToSrv(ctx context.Context, args forwardrpc.GameInternalMessage, reply *forwardrpc.Resp) (err error) { var resp = &forwardrpc.Resp{} resp, err = handles.BroadcastMsgToSrv(args) if err != nil { reply.Errmsg = resp.Errmsg reply.Errno = resp.Errno fmt.Println("@@@@@@@@@@@@@@: ", err) logging.Errorf("BroadcastMsgToSrv error args:%#v, reply:%#v, err: %s!", args, reply, err.Error()) return } reply.Errmsg = resp.Errmsg reply.Errno = resp.Errno return } 响应结构体: message Resp{ string errno = 1; // 错误码 string errmsg = 2; // 错误信息 } github.com/smallnest/rpcx v1.8.15
现在是客户端收不到err值,都是nil
客户端调用代码: func SendToGameSrvBroadcast(reg forwardrpc.GameInternalMessage) error { // 调用rpc 返回结果 // 设置客户端的超时时间为 5 秒 ctx, cancel := context.WithTimeout(context.Background(), 5time.Second) defer cancel() _, err := forwardrpcCli.BroadcastMsgToSrv(ctx, reg) if err != nil { fmt.Println(err.Error()) return errorx.Wrap(err) } return nil }
打印err: @@@@@@@@@@@@@@: 2023-11-13 12:25:49 | D:/go/src/forwardSrv/pkg/rpcClient/rpc_client.go:153 | can not found any server 2023-11-13 12:25:49 | D:/go/src/forwardSrv/pkg/handles/handlers.go:197 | can not found any server
func (c Client) RefreshConfig(ctx context.Context, args RefreshConfigReq) (reply *Resp, err error) { reply = &Resp{} err = c.xclient.Call(ctx, "RefreshConfig", args, reply) fmt.Println("$$$$$$$$$$$$$$$$$: ", reply) return reply, err }
打印结果: $$$$$$$$$$$$$$$$$:
panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x18 pc=0x169bb46] 请问怎么解决,reply 拿到的是一个空的
github.com/smallnest/rpcx v1.8.11 // indirect