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

Commit

Permalink
Apply connect timeout to Dial
Browse files Browse the repository at this point in the history
  • Loading branch information
vcabbage committed Sep 4, 2019
1 parent 1c663ac commit 5f7db87
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ func Dial(addr string, opts ...ConnOption) (*Client, error) {
if err != nil {
return nil, err
}

dialer := &net.Dialer{Timeout: c.connectTimeout}
switch u.Scheme {
case "amqp", "":
c.net, err = net.Dial("tcp", host+":"+port)
c.net, err = dialer.Dial("tcp", host+":"+port)
case "amqps":
c.initTLSConfig()
c.tlsNegotiation = false
c.net, err = tls.Dial("tcp", host+":"+port, c.tlsConfig)
c.net, err = tls.DialWithDialer(dialer, "tcp", host+":"+port, c.tlsConfig)
default:
return nil, errorErrorf("unsupported scheme %q", u.Scheme)
}
Expand Down

0 comments on commit 5f7db87

Please sign in to comment.