diff --git a/bff/internal/wsClient/client.go b/bff/internal/wsClient/client.go index d829025..53bb66e 100644 --- a/bff/internal/wsClient/client.go +++ b/bff/internal/wsClient/client.go @@ -15,17 +15,14 @@ import ( func PercutaneousAddUser(rpcMgr *wsproxy.RpcClientManager) http.HandlerFunc { return request.UserReadMiddleware(func(w http.ResponseWriter, r *http.Request) { - logx.Infof("BFF ws handler start, raw url=%s", r.URL.String()) cli, ready := rpcMgr.GetClient() if !ready { logx.Error("BFF: rpc client not ready, return 503") http.Error(w, "rpc service unavailable", http.StatusServiceUnavailable) return } - logx.Info("BFF: rpc client ready") hostCode := r.URL.Query().Get("host_code") - logx.Infof("BFF: get host_code from query, val=%s", hostCode) if hostCode == "" { logx.Error("BFF: host_code is empty") http.Error(w, "missing host_code query param", http.StatusBadRequest) @@ -34,16 +31,13 @@ func PercutaneousAddUser(rpcMgr *wsproxy.RpcClientManager) http.HandlerFunc { proxyHandler := wsproxy.NewWsProxyHandler( func(parentCtx context.Context) (grpc.ClientStream, error) { - logx.Info("BFF: enter grpc stream create callback") streamCli := percutaneous.NewPercutaneousClient(cli.Conn()) stream, err := streamCli.WsAddUserStream(parentCtx) if err != nil { logx.Errorf("BFF: create WsAddUserStream failed, err=%v", err) return nil, err } - logx.Info("BFF: grpc stream create SUCCESS") - // =========核心新增:BFF自动发送第一条host_code消息给percutaneous========= jsonStr := fmt.Sprintf(`{"host_code":"%s"}`, hostCode) reqMsg := &percutaneous.WsStreamRequest{ RawBody: []byte(jsonStr), @@ -53,16 +47,12 @@ func PercutaneousAddUser(rpcMgr *wsproxy.RpcClientManager) http.HandlerFunc { logx.Errorf("BFF: auto send host_code msg failed, err=%v, json=%s", err, jsonStr) return nil, err } - logx.Infof("BFF: auto send host_code message success, content=%s", jsonStr) - // ===================================================================== return stream, nil }, func() protoreflect.ProtoMessage { return &percutaneous.WsStreamRequest{} }, ) - logx.Info("BFF: start run proxyHandler") proxyHandler(w, r) - logx.Info("BFF: proxyHandler finished, ws stream closed") }) } diff --git a/services/percutaneous/internal/logic/wsAddUserStreamLogic.go b/services/percutaneous/internal/logic/wsAddUserStreamLogic.go index fccf268..ed27e94 100644 --- a/services/percutaneous/internal/logic/wsAddUserStreamLogic.go +++ b/services/percutaneous/internal/logic/wsAddUserStreamLogic.go @@ -48,7 +48,6 @@ func NewWsAddUserStreamLogic(ctx context.Context, svcCtx *svc.ServiceContext) *W // 添加用户 func (l *WsAddUserStreamLogic) WsAddUserStream(stream percutaneous.Percutaneous_WsAddUserStreamServer) error { - l.Logger.Info("in coming ws tunnel stream") ctx := stream.Context() timeout := time.Duration(utils.GetConfigInt("ws.out_time")) * time.Second ctx, cancel := context.WithTimeout(ctx, timeout) @@ -65,12 +64,10 @@ func (l *WsAddUserStreamLogic) WsAddUserStream(stream percutaneous.Percutaneous_ var hostCode struct { Code string `json:"host_code"` } - l.Logger.Errorf(" host_code raw msg is: %v", string(recvFrame.RawBody)) // 保留你确认的 !err 判断 if ok := utils.JsonStringToStruct(string(recvFrame.RawBody), &hostCode); !ok { return status.Errorf(codes.InvalidArgument, "device code parse error") } - l.Logger.Infof("device connected, code=%s", hostCode.Code) msgCh := make(chan []byte, 1) wrapper := &grpcStreamWrapper{stream: stream} @@ -82,7 +79,6 @@ func (l *WsAddUserStreamLogic) WsAddUserStream(stream percutaneous.Percutaneous_ } l.svcCtx.SessionMgr.Register(hostCode.Code, sess) defer l.svcCtx.SessionMgr.Remove(hostCode.Code) - l.Logger.Info("session register success, waiting for scan event") select { case <-ctx.Done():