From e2d12a25e0092a5be1f740fa76e4a2a38f33015a Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 7 Feb 2022 12:33:38 +0200 Subject: [PATCH] lib/netutil: increase dial timeout from 1 second to 5 seconds There are real-world cases when TCP connection needs more than 1 second to be established. --- lib/netutil/tcpdialer.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/netutil/tcpdialer.go b/lib/netutil/tcpdialer.go index 688d377551..faf5a243c9 100644 --- a/lib/netutil/tcpdialer.go +++ b/lib/netutil/tcpdialer.go @@ -15,7 +15,11 @@ import ( func NewTCPDialer(name, addr string) *TCPDialer { d := &TCPDialer{ d: &net.Dialer{ - Timeout: time.Second, + // The timeout for establishing a TCP connection. + // 5 seconds should be enough for the majority of cases. + Timeout: 5 * time.Second, + + // How frequently to send keep-alive packets over established TCP connections. KeepAlive: time.Second, },