Skip to content

Commit 4cf6c22

Browse files
fix(TCP): use backoff under each circumstance
1 parent 84931dc commit 4cf6c22

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

backend/pkg/transport/network/tcp/client.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package tcp
22

33
import (
4-
"errors"
54
"fmt"
65
"net"
7-
"syscall"
86
"time"
97

108
"github.com/rs/zerolog"
@@ -38,6 +36,7 @@ func (client *Client) Dial() (net.Conn, error) {
3836

3937
var err error
4038
var conn net.Conn
39+
client.currentRetries = 0
4140
client.logger.Info().Msg("dialing")
4241

4342
for client.config.MaxConnectionRetries <= 0 || client.currentRetries < client.config.MaxConnectionRetries {
@@ -64,8 +63,8 @@ func (client *Client) Dial() (net.Conn, error) {
6463
return nil, client.config.Context.Err()
6564
}
6665

67-
// Check if we should retry this error
68-
if netErr, ok := err.(net.Error); !client.config.TryReconnect || (!errors.Is(err, syscall.ECONNREFUSED) && (!ok || !netErr.Timeout())) {
66+
// If reconnection is disabled, bail out immediately on any error
67+
if !client.config.TryReconnect {
6968
client.logger.Error().Stack().Err(err).Msg("failed with non-retryable error")
7069
return nil, err
7170
}

0 commit comments

Comments
 (0)