From 46bf1afdaf419b7da59ded2284623905508f3dd7 Mon Sep 17 00:00:00 2001 From: Josh Padnick Date: Mon, 5 Feb 2018 01:29:16 +0100 Subject: [PATCH] Close the TCP connection after each attempt. Solves https://github.com/gruntwork-io/health-checker/issues/5. --- server/server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/server.go b/server/server.go index d949d1e..7cb5774 100644 --- a/server/server.go +++ b/server/server.go @@ -74,11 +74,13 @@ func attemptTcpConnection(port int, opts *options.Options) error { defaultTimeout := time.Second * 5 - _, err := net.DialTimeout("tcp", fmt.Sprintf("0.0.0.0:%d", port), defaultTimeout) + conn, err := net.DialTimeout("tcp", fmt.Sprintf("0.0.0.0:%d", port), defaultTimeout) if err != nil { return err } + defer conn.Close() + return nil }