From a793eb11e146b0638e1f0d17b1c6cd6a0253aff3 Mon Sep 17 00:00:00 2001 From: dingjun Date: Mon, 6 Jul 2020 20:02:42 +0800 Subject: [PATCH] close connection --- server_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server_test.go b/server_test.go index 55cc01d..c1b83cf 100644 --- a/server_test.go +++ b/server_test.go @@ -62,6 +62,8 @@ func _sendAndRecvTCP(addr string, msg string) string { return "" } + defer c.Close() + _, err = c.Write([]byte(msg)) if err != nil { log.Errorln(err) @@ -83,14 +85,21 @@ func _sendAndRecvWS(addr string, msg string) string { log.Errorln(err) return "" } + resp.Body.Close() + if resp.StatusCode != http.StatusSwitchingProtocols { log.Errorf("dial ws code %d", resp.StatusCode) + return "" } + + defer c1.Close() + err = c1.WriteMessage(websocket.BinaryMessage, []byte(msg)) if err != nil { log.Errorln(err) return "" } + _, d, err := c1.ReadMessage() if err != nil { log.Errorln(err)