diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 01df20fe..7ba85da9 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -76,9 +76,11 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp return } defer conn.Close() + w.Header().Set("Connection", "Upgrade") rsp := types.DataTransferData{} //鉴权不成功10秒后断开 - /*if !l.checkAuth(svcCtx, r) { + if !l.checkAuth(svcCtx, r) { + time.Sleep(time.Second) //兼容下火狐 rsp.T = constants.WEBSOCKET_UNAUTH b, _ := json.Marshal(rsp) //先发一条正常信息 @@ -86,7 +88,7 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp //发送关闭信息 _ = conn.WriteMessage(websocket.CloseMessage, nil) return - }*/ + } //生成连接唯一标识 flag := uuid.New().String() + "" ws := wsConnectItem{ @@ -104,6 +106,7 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp mapConnPool.Store(flag, ws) defer ws.close() //把连接成功消息发回去 + time.Sleep(time.Second) //兼容下火狐 rsp.T = constants.WEBSOCKET_CONNECT_SUCCESS rsp.D = flag b, _ := json.Marshal(rsp)