diff --git a/testclient_test.go b/testclient_test.go index 63ffc78..9dc275a 100644 --- a/testclient_test.go +++ b/testclient_test.go @@ -227,7 +227,13 @@ func (c *TestClient) CloseWithBye() { } func (c *TestClient) Close() { - c.conn.WriteMessage(websocket.CloseMessage, []byte{}) // nolint + if err := c.conn.WriteMessage(websocket.CloseMessage, []byte{}); err == websocket.ErrCloseSent { + // Already closed + return + } + + // Wait a bit for close message to be processed. + time.Sleep(100 * time.Millisecond) c.conn.Close() // Drain any entries in the channels to terminate the read goroutine.