This commit is contained in:
laodaming 2023-07-26 19:19:20 +08:00
parent 636bc0aee7
commit f609fa364d

View File

@ -142,7 +142,7 @@ func (l *DataTransferLogic) checkAuth(svcCtx *svc.ServiceContext, r *http.Reques
// 心跳
func (w *wsConnectItem) heartbeat() {
tick := time.Tick(time.Second * 10)
tick := time.Tick(time.Second * 2)
for {
select {
case <-w.closeChan:
@ -166,6 +166,7 @@ func (w *wsConnectItem) close() {
defer w.mutex.Unlock()
logx.Info("websocket:", w.flag, " is closing...")
//发送关闭信息
_ = w.conn.SetWriteDeadline(time.Now().Add(time.Second))
_ = w.conn.WriteMessage(websocket.CloseMessage, nil)
w.conn.Close()
mapConnPool.Delete(w.flag)