Browse code

Add a timeout when trying to connect to the server, otherwise sometimes it just hangs

Signed-off-by: Doug Davis <dug@us.ibm.com>

Doug Davis authored on 2014/09/15 20:50:22
Showing 1 changed files
... ...
@@ -16,6 +16,7 @@ import (
16 16
 	"strconv"
17 17
 	"strings"
18 18
 	"syscall"
19
+	"time"
19 20
 
20 21
 	"github.com/docker/docker/api"
21 22
 	"github.com/docker/docker/dockerversion"
... ...
@@ -34,7 +35,8 @@ func (cli *DockerCli) HTTPClient() *http.Client {
34 34
 	tr := &http.Transport{
35 35
 		TLSClientConfig: cli.tlsConfig,
36 36
 		Dial: func(network, addr string) (net.Conn, error) {
37
-			return net.Dial(cli.proto, cli.addr)
37
+			// Why 32? See issue 8035
38
+			return net.DialTimeout(cli.proto, cli.addr, 32*time.Second)
38 39
 		},
39 40
 	}
40 41
 	return &http.Client{Transport: tr}