From 40b1163cc1faad5b99704e69b372815f27a7734d Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 16:20:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E5=88=B0=E6=B8=B2=E6=9F=93=E9=9B=86=E7=BE=A4=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 2 +- websocket.go | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 1a67da2..0c26844 100644 --- a/main.go +++ b/main.go @@ -36,7 +36,7 @@ var DequeueHandler = triggered.RegisterExecute(func(params *triggered.Params[boo return } - log.Println(item) + // log.Println(item) PopChannel <- item } }) diff --git a/websocket.go b/websocket.go index ee28295..496f32b 100644 --- a/websocket.go +++ b/websocket.go @@ -68,6 +68,14 @@ func queueHandler(w http.ResponseWriter, r *http.Request) { } } + err = conn.SetWriteDeadline(time.Now().Add(time.Second * 15)) + if err != nil { + log.Println(err) + log.Println("重新回队") + stateClient.PushItem(nil, item) + return + } + // 写回消息 err = conn.WriteMessage(websocket.BinaryMessage, wdata) if err != nil { @@ -78,15 +86,6 @@ func queueHandler(w http.ResponseWriter, r *http.Request) { } // 打印消息 fmt.Printf("%s 处理完成. len\n", conn.RemoteAddr()) - - // 读取消息 - // msgType, msg, err := conn.ReadMessage() - - // if err != nil { - // log.Println(msgType, msg, err) - // return - // } - } }