Skip to content

Commit

Permalink
Merge pull request #74 from Jardaliao/fix-close-websocket-invalid-sta…
Browse files Browse the repository at this point in the history
…tus-code

fix: closing websocket connection returns invalid status code
  • Loading branch information
AlexStocks authored Nov 20, 2023
2 parents 929d524 + 31cf517 commit 28c6c73
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion transport/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,8 @@ func (w *gettyWSConn) writePong(message []byte) error {
// close websocket connection
func (w *gettyWSConn) close(waitSec int) {
w.updateWriteDeadline()
w.conn.WriteMessage(websocket.CloseMessage, []byte("bye-bye!!!"))
bytes := websocket.FormatCloseMessage(websocket.CloseNormalClosure, "bye-bye!!!")
w.conn.WriteMessage(websocket.CloseMessage, bytes)
conn := w.conn.UnderlyingConn()
if tcpConn, ok := conn.(*net.TCPConn); ok {
tcpConn.SetLinger(waitSec)
Expand Down

0 comments on commit 28c6c73

Please sign in to comment.