diff --git a/constants/websocket.go b/constants/websocket.go index 34c682d9..84321556 100644 --- a/constants/websocket.go +++ b/constants/websocket.go @@ -25,5 +25,5 @@ const ( //通用回调通知 WEBSOCKET_COMMON_NOTIFY Websocket = "WEBSOCKET_COMMON_NOTIFY" //数据接收速度超过数据消费速度(缓冲队列满了) - WEBSOCKET_REQUEST_CACHE_QUEUE_OVERFLOW = "WEBSOCKET_REQUEST_CACHE_QUEUE_OVERFLOW" + WEBSOCKET_INCOME_CACHE_QUEUE_OVERFLOW = "WEBSOCKET_INCOME_CACHE_QUEUE_OVERFLOW" ) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index ddf752af..53a2d2c6 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -348,7 +348,8 @@ func (w *wsConnectItem) sendToOutChan(data []byte) { return case w.outChan <- data: return - case <-time.After(time.Second * 3): //阻塞超过3秒丢弃 + case <-time.After(time.Millisecond * 200): //阻塞超过200ms丢弃 + logx.Error("failed to send to out chan,time expired,data:", string(data)) return } } @@ -361,7 +362,7 @@ func (w *wsConnectItem) sendToInChan(data []byte) { case w.inChan <- data: return case <-time.After(time.Millisecond * 200): //200豪秒超时丢弃,说明超过消费速度了 - w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_CACHE_QUEUE_OVERFLOW, "send message is too frequent,Please reduce the sending speed!!!")) + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_INCOME_CACHE_QUEUE_OVERFLOW, "send message is too frequent,Please reduce the sending speed ,otherwise, the message you sent may be lost")) return } }