diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 60d59d24..207a2833 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -204,20 +204,24 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use //合成client后缀,不是同个后缀的不能复用 userPart := getUserJoinPart(userInfo.UserId, userInfo.GuestId, userAgent) lenUserPart := len(userPart) + canUseOldWid := true + //长度太短 if lendecryptionWid <= lenUserPart { - return wsConnectItem{}, errors.New("length of client id is too short") + canUseOldWid = false } //尾部不同不能复用 if decryptionWid[lendecryptionWid-lenUserPart:] != userPart { - return wsConnectItem{}, errors.New("the client id is not belong to you before") + canUseOldWid = false } //存在是不能给他申请重新绑定 if _, ok := mapConnPool.Load(oldWid); ok { - return wsConnectItem{}, errors.New("the wid has bond by other connect") + canUseOldWid = false } //检测通过可以用旧的 - logx.Info("====复用旧的ws连接成功====") - uniqueId = oldWid + if canUseOldWid { + logx.Info("====复用旧的ws连接成功====") + uniqueId = oldWid + } } renderCtx, renderCtxCancelFunc := context.WithCancel(l.ctx) ws := wsConnectItem{