Browse code

Merge pull request #8035 from duglin/Issue7965

Add timeout to client - fix for #7965

Alexandr Morozov authored on 2014/09/17 06:55:48
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}