From 76f3ca3c6f82018f98ddc230c2d49bc3573e6f16 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Fri, 2 Sep 2022 16:14:37 +0900 Subject: [PATCH] fix: close previous connection before starting new one --- ftwhttp/client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ftwhttp/client.go b/ftwhttp/client.go index 1db65c1..97cec56 100644 --- a/ftwhttp/client.go +++ b/ftwhttp/client.go @@ -29,6 +29,12 @@ func NewClient() *Client { // NewConnection creates a new Connection based on a Destination func (c *Client) NewConnection(d Destination) error { + if c.Transport != nil { + if err := c.Transport.connection.Close(); err != nil { + return err + } + } + var err error var netConn net.Conn