From 468382f9a70f9edbe53cd5da39208868b702298e Mon Sep 17 00:00:00 2001 From: xiaozirun <807046079@qq.com> Date: Thu, 14 Nov 2024 11:31:39 +0800 Subject: [PATCH] fix: websocket close frame not response --- router/websocket/websocket.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/router/websocket/websocket.go b/router/websocket/websocket.go index 6d2c395..e7d3bc1 100644 --- a/router/websocket/websocket.go +++ b/router/websocket/websocket.go @@ -18,8 +18,7 @@ func Use(handler func(conn *websocket.Conn, ctx *gin.Context) error) gin.Handler return func(ctx *gin.Context) { conn, err := upgrader.Upgrade(ctx.Writer, ctx.Request, nil) if err != nil { - ctx.JSONP(500, "error") - return + panic(err) } conn.SetPingHandler( func(message string) error { @@ -33,11 +32,7 @@ func Use(handler func(conn *websocket.Conn, ctx *gin.Context) error) gin.Handler }, ) conn.SetPongHandler(nil) - conn.SetCloseHandler( - func(code int, text string) error { - return nil - }, - ) + conn.SetCloseHandler(nil) defer conn.Close() err = handler(conn, ctx) if err != nil {