From 16dc79e64a32cb5a439438a328f6c8e34789b530 Mon Sep 17 00:00:00 2001 From: Tsachi Herman Date: Fri, 22 Oct 2021 14:42:28 -0400 Subject: [PATCH] make sure to flush control messages before closing the unerlying connection. --- conn.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/conn.go b/conn.go index b929ef82..92a8ab12 100644 --- a/conn.go +++ b/conn.go @@ -548,7 +548,12 @@ func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) er if messageType == CloseMessage { c.writeFatal(ErrCloseSent) } - return err + + if err != nil { + return err + } + + return c.flush() } // beginMessage prepares a connection and message writer for a new message.