Skip to content

Commit 06962e3

Browse files
committed
add negative duration fix for tcp proxydial and also fix documentation
1 parent 5993a5f commit 06962e3

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

dialoptions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ func WithTimeout(d time.Duration) DialOption {
414414
// returned by f, gRPC checks the error's Temporary() method to decide if it
415415
// should try to reconnect to the network address.
416416
//
417-
// Note: As of Go 1.13, the standard library overrides the OS defaults for
417+
// Note: As of Go 1.21, the standard library overrides the OS defaults for
418418
// TCP keepalive time and interval to 15s.
419419
// To retain OS defaults, use a net.Dialer with the KeepAlive field set to a
420420
// negative value.

internal/transport/proxy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"net/http"
2929
"net/http/httputil"
3030
"net/url"
31+
"time"
3132
)
3233

3334
const proxyAuthHeaderKey = "Proxy-Authorization"
@@ -122,7 +123,7 @@ func proxyDial(ctx context.Context, addr string, grpcUA string) (conn net.Conn,
122123
newAddr = proxyURL.Host
123124
}
124125

125-
conn, err = (&net.Dialer{}).DialContext(ctx, "tcp", newAddr)
126+
conn, err = (&net.Dialer{KeepAlive: time.Duration(-1)}).DialContext(ctx, "tcp", newAddr)
126127
if err != nil {
127128
return
128129
}

server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ func (l *listenSocket) Close() error {
814814
// this method returns.
815815
// Serve will return a non-nil error unless Stop or GracefulStop is called.
816816
//
817-
// Note: As of Go 1.13, the standard library overrides the OS defaults for
817+
// Note: As of Go 1.21, the standard library overrides the OS defaults for
818818
// TCP keepalive time and interval to 15s.
819819
// To retain OS defaults, pass a net.Listener created by calling the Listen method
820820
// on a net.ListenConfig with the `KeepAlive` field set to a negative value.

0 commit comments

Comments
 (0)