From 8a8d0404ce817ec490cf7995468ce5ffba8fc3ea Mon Sep 17 00:00:00 2001 From: Vincent Batoufflet Date: Mon, 26 Feb 2018 08:45:28 +0100 Subject: [PATCH] Add missing keepalive on TCP connection --- client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index d20ec7a..be9870a 100644 --- a/client.go +++ b/client.go @@ -47,7 +47,9 @@ func (c *Client) Exec(r Request) (*Response, error) { return nil, err } - if !r.keepAlive() { + if r.keepAlive() { + c.conn.(*net.TCPConn).SetKeepAlive(true) + } else { defer c.Close() } }