Commit bcc16008 authored by hanneloresx's avatar hanneloresx
Browse files

Re-try connection in case of timeout

Try TCP connection again if the first error was a timeout.
parent 2ed24be8
......@@ -9,6 +9,7 @@ import (
"net/url"
"strings"
"time"
"os"
)
// timeout specifies the number of seconds we're willing to wait until we
......@@ -44,10 +45,14 @@ func IsTCPPortReachable(addrTuple string) (r Result) {
r.Target = addrTuple
conn, err := net.DialTimeout("tcp", addrTuple, timeout)
if os.IsTimeout(err) {
conn, err = net.DialTimeout("tcp", addrTuple, timeout)
}
if err != nil {
r.Error = err
return
}
conn.Close()
r.Error = nil
return
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment