diff --git a/clientv3/client.go b/clientv3/client.go index 51aba8b00..c3014bb4a 100644 --- a/clientv3/client.go +++ b/clientv3/client.go @@ -322,7 +322,7 @@ func (c *Client) dial(endpoint string, dopts ...grpc.DialOption) (*grpc.ClientCo opts = append(opts, c.cfg.DialOptions...) - conn, err := grpc.Dial(host, opts...) + conn, err := grpc.DialContext(c.ctx, host, opts...) if err != nil { return nil, err } @@ -367,7 +367,9 @@ func newClient(cfg *Config) (*Client, error) { } client.balancer = newSimpleBalancer(cfg.Endpoints) - conn, err := client.dial("", grpc.WithBalancer(client.balancer)) + // use Endpoints[0] so that for https:// without any tls config given, then + // grpc will assume the ServerName is in the endpoint. + conn, err := client.dial(cfg.Endpoints[0], grpc.WithBalancer(client.balancer)) if err != nil { client.cancel() client.balancer.Close()