Skip to content
This repository was archived by the owner on Dec 14, 2020. It is now read-only.

Commit 5f7db87

Browse files
committed
Apply connect timeout to Dial
1 parent 1c663ac commit 5f7db87

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ func Dial(addr string, opts ...ConnOption) (*Client, error) {
7070
if err != nil {
7171
return nil, err
7272
}
73+
74+
dialer := &net.Dialer{Timeout: c.connectTimeout}
7375
switch u.Scheme {
7476
case "amqp", "":
75-
c.net, err = net.Dial("tcp", host+":"+port)
77+
c.net, err = dialer.Dial("tcp", host+":"+port)
7678
case "amqps":
7779
c.initTLSConfig()
7880
c.tlsNegotiation = false
79-
c.net, err = tls.Dial("tcp", host+":"+port, c.tlsConfig)
81+
c.net, err = tls.DialWithDialer(dialer, "tcp", host+":"+port, c.tlsConfig)
8082
default:
8183
return nil, errorErrorf("unsupported scheme %q", u.Scheme)
8284
}

0 commit comments

Comments
 (0)