-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
This is a bug. A keepalive error is a connection failure, not a deadline event.
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
due to KeepAlive failure. (Go 1.12, Linux, amd64)
The Error should 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()
string should mention keepalive. It's currently:
"read tcp n.n.n.n:p->n.n.n.n:p: read: connection timed out"
Related: net.Dialer.KeepAlive gets 15*time.Second if unset/zero. This isn't documented in package net.
cc @bradfitz