Skip to content

Commit 28c6c73

Browse files
authored
Merge pull request #74 from Jardaliao/fix-close-websocket-invalid-status-code
fix: closing websocket connection returns invalid status code
2 parents 929d524 + 31cf517 commit 28c6c73

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

transport/connection.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,8 @@ func (w *gettyWSConn) writePong(message []byte) error {
639639
// close websocket connection
640640
func (w *gettyWSConn) close(waitSec int) {
641641
w.updateWriteDeadline()
642-
w.conn.WriteMessage(websocket.CloseMessage, []byte("bye-bye!!!"))
642+
bytes := websocket.FormatCloseMessage(websocket.CloseNormalClosure, "bye-bye!!!")
643+
w.conn.WriteMessage(websocket.CloseMessage, bytes)
643644
conn := w.conn.UnderlyingConn()
644645
if tcpConn, ok := conn.(*net.TCPConn); ok {
645646
tcpConn.SetLinger(waitSec)

0 commit comments

Comments
 (0)