From 1381b44adf836f6ce5995f16006641d935af9d77 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Fri, 19 Jun 2015 16:50:44 -0700 Subject: [PATCH] discovery: add timeouts for discovery client --- discovery/discovery.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/discovery/discovery.go b/discovery/discovery.go index b713d0ff7..dbc041c22 100644 --- a/discovery/discovery.go +++ b/discovery/discovery.go @@ -18,6 +18,7 @@ import ( "errors" "fmt" "math" + "net" "net/http" "net/url" "path" @@ -120,7 +121,15 @@ func newDiscovery(durl, dproxyurl string, id types.ID) (*discovery, error) { return nil, err } cfg := client.Config{ - Transport: &http.Transport{Proxy: pf}, + Transport: &http.Transport{ + Proxy: pf, + Dial: (&net.Dialer{ + Timeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + }).Dial, + TLSHandshakeTimeout: 10 * time.Second, + ResponseHeaderTimeout: 5 * time.Second, + }, Endpoints: []string{u.String()}, } c, err := client.New(cfg)