Description
Go version
go1.24.1
Output of go env
in your module/workspace:
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN='/Users/bplessis/.local/bin/'
GOCACHE='/Users/bplessis/.cache/go'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/bplessis/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/rr/d6ybyfkx60z5961g5t_b0x4h0000gn/T/go-build1599168907=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/bplessis/travail/devs/mqttfe/go.mod'
GOMODCACHE='/Users/bplessis/.local/share/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/bplessis/.local/share/go:/Users/bplessis/travail/devs/go/'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.24.2/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/bplessis/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.24.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.2'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
Hi,
I had a weird time fighting go default tcp keepalive for a service that is connecting IoT devices to a go-based server.
No amount of SetKeepAlive(false) or SetKeepAlive(300) was doing anything to solve my issue and it's only after quite a lot of failures that i fell upon the https://pkg.go.dev/net#ListenConfig structure definition and the following excerpt:
// KeepAlive specifies the keep-alive period for network
// connections accepted by this listener.
//
// KeepAlive is ignored if KeepAliveConfig.Enable is true.
This lead me to replacing SetKeepAlive(false)
with .SetKeepAliveConfig(net.KeepAliveConfig{Enable: false})
and that started to actually do something.
So given that apparently the default keepalive is set using this new mechanism we shoud mark the old function as deprecated or at least add a big warning of the interaction with SetKeepAliveConfig() in the SetKeepAlive()/SetKeepAlivePeriod() definition ?
What did you see happen?
SetKeepAlive/SetKeepAlivePeriod did not have any effect on the keepalive mechanism and there was no direct documentation on the function definition that helped identify the "conflict" with the KeepAliveConfig structure/settings
What did you expect to see?
SetKeepAlive/SetKeepAlivePeriod doc should include a warning or flag the function as deprecated
Activity
gabyhelp commentedon Apr 16, 2025
Related Issues
Related Code Changes
Related Discussions
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
bplessis-swi commentedon Apr 17, 2025
Closing after re-testing, sorry assumptions where made due to previous code and i missed something, my root issue was not due to KeepAliveConfig being enabled by default.