Skip to content

Commit

Permalink
fix: websocket close frame not response
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozirun committed Nov 14, 2024
1 parent 4a4ed4b commit 468382f
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions router/websocket/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 468382f

Please sign in to comment.