From 2a06a28ad68701b168faf9eae4e40aef392dc7a8 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 27 Jul 2023 10:46:08 +0800 Subject: [PATCH] fix --- server/websocket/internal/logic/datatransferlogic.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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)