@@ -36,14 +36,15 @@ import (
36
36
"golang.org/x/net/http2/hpack"
37
37
"google.golang.org/grpc/codes"
38
38
"google.golang.org/grpc/credentials"
39
+ "google.golang.org/grpc/internal"
39
40
"google.golang.org/grpc/internal/channelz"
40
41
icredentials "google.golang.org/grpc/internal/credentials"
41
42
"google.golang.org/grpc/internal/grpclog"
42
43
"google.golang.org/grpc/internal/grpcsync"
43
44
"google.golang.org/grpc/internal/grpcutil"
44
45
imetadata "google.golang.org/grpc/internal/metadata"
45
46
istatus "google.golang.org/grpc/internal/status"
46
- "google.golang.org/grpc/internal/syscall"
47
+ isyscall "google.golang.org/grpc/internal/syscall"
47
48
"google.golang.org/grpc/internal/transport/networktype"
48
49
"google.golang.org/grpc/keepalive"
49
50
"google.golang.org/grpc/metadata"
@@ -176,9 +177,7 @@ func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error
176
177
if networkType == "tcp" && useProxy {
177
178
return proxyDial (ctx , address , grpcUA )
178
179
}
179
- // KeepAlive is set to a negative value to prevent Go's override of the TCP
180
- // keepalive time and interval; retain the OS default.
181
- return (& net.Dialer {KeepAlive : time .Duration (- 1 )}).DialContext (ctx , networkType , address )
180
+ return internal .NetDialerWithTCPKeepalive ().DialContext (ctx , networkType , address )
182
181
}
183
182
184
183
func isTemporary (err error ) bool {
@@ -264,7 +263,7 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
264
263
}
265
264
keepaliveEnabled := false
266
265
if kp .Time != infinity {
267
- if err = syscall .SetTCPUserTimeout (conn , kp .Timeout ); err != nil {
266
+ if err = isyscall .SetTCPUserTimeout (conn , kp .Timeout ); err != nil {
268
267
return nil , connectionErrorf (false , err , "transport: failed to set TCP_USER_TIMEOUT: %v" , err )
269
268
}
270
269
keepaliveEnabled = true
0 commit comments