From 1b537104c8323a8369b29092d052426c69bf5008 Mon Sep 17 00:00:00 2001 From: Mostafa Moradian Date: Fri, 17 Nov 2023 19:00:18 +0100 Subject: [PATCH] Dial without timeout if zero value is passed --- network/client.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/network/client.go b/network/client.go index a01f9235..2ba17e00 100644 --- a/network/client.go +++ b/network/client.go @@ -86,7 +86,15 @@ func NewClient(ctx context.Context, clientConfig *config.Client, logger zerolog. } // Create a new connection. - conn, origErr := net.DialTimeout(client.Network, client.Address, client.DialTimeout) + var ( + conn net.Conn + origErr error + ) + if client.DialTimeout == 0 { + conn, origErr = net.Dial(client.Network, client.Address) + } else { + conn, origErr = net.DialTimeout(client.Network, client.Address, client.DialTimeout) + } if origErr != nil { err := gerr.ErrClientConnectionFailed.Wrap(origErr) logger.Error().Err(err).Msg("Failed to create a new connection")