Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Conn.Read() returns Error with .Timeout()==true on KeepAlive failure #31449

Open
networkimprov opened this Issue Apr 12, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@networkimprov
Copy link

commented Apr 12, 2019

net Docs say:

A zero value for [deadline] means I/O operations will not time out.

A zero value for [read deadline] means Read will not time out.

KeepAlive specifies the keep-alive period for an active network connection.
If zero, keep-alives are enabled if supported by the protocol and operating system.
Network protocols or operating systems that do not support keep-alives ignore this field.
If negative, keep-alives are disabled.

For a TLS connection that's been severed, Conn.Read() returns a net.Error with .Timeout()==true after ~18 minutes, apparently due to KeepAlive failure. (Go 1.12, Linux, amd64)

The Error should probably give .Timeout()==false to comply with the docs. Code that checks for .Timeout()==true would generally assume that an explicit deadline had passed.

The .Error() value should mention keepalive. It's currently:
"read tcp n.n.n.n:p->n.n.n.n:p: read: connection timed out"

Since 1.11, net.Dialer.KeepAlive gets 15*time.Second if unset/zero. This isn't documented in package net.

cc @bradfitz

@networkimprov

This comment has been minimized.

Copy link
Author

commented Apr 16, 2019

Also filed #31490 to report that tls.DialWithDialer() doesn't respect .KeepAlive.

@CAFxX

This comment has been minimized.

Copy link
Contributor

commented Apr 17, 2019

Since 1.11, net.Dialer.KeepAlive gets 15*time.Second if unset/zero. This isn't documented in package net.

It is documented that we enable keep-alives if that field is unset/zero. The choice of not specifying 15s in the docs was deliberate and is actually documented in the commit message: 5bd7e9c

@julieqiu julieqiu added this to the Go1.13 milestone Apr 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.