diff --git a/manager/state/raft/util.go b/manager/state/raft/util.go index 75872fe77c..1a49f76cb4 100644 --- a/manager/state/raft/util.go +++ b/manager/state/raft/util.go @@ -2,6 +2,7 @@ package raft import ( "context" + "net" "time" "github.com/docker/swarmkit/api" @@ -14,11 +15,15 @@ import ( // dial returns a grpc client connection func dial(addr string, protocol string, creds credentials.TransportCredentials, timeout time.Duration) (*grpc.ClientConn, error) { + // gRPC dialer connects to proxy first. Provide a custom dialer here avoid that. grpcOptions := []grpc.DialOption{ grpc.WithBackoffMaxDelay(2 * time.Second), grpc.WithTransportCredentials(creds), grpc.WithUnaryInterceptor(grpc_prometheus.UnaryClientInterceptor), grpc.WithStreamInterceptor(grpc_prometheus.StreamClientInterceptor), + grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { + return net.DialTimeout("tcp", addr, timeout) + }), } if timeout != 0 {