Skip to content

Keep-alive interval may be set incorrectly #7144

@matteocontrini

Description

@matteocontrini

I may be missing something but I was looking at how the Caddy keepalive_interval option is set on the underlying TCP connection and I think that it's not applied correctly.

Caddy sets the keep alive interval setting here in net.ListenConfig:

lnAny, err := listenAddr.Listen(app.ctx, portOffset, net.ListenConfig{KeepAlive: time.Duration(srv.KeepAliveInterval)})

Which according to the Go reference is the "keep-alive period for network connections accepted by this listener".

Looking closely, it seems that the effect of this field was changed in Go 1.23. See issue golang/go#62254 and commit golang/go@d42cd45#diff-47db4c2365e40cb132dfeabd4c9c8beac05c435e02e27dfcf03ce431c9900da9

Previously, setting the KeepAlive option on net.ListenConfig would set the keep-alive interval period (see here in Go 1.22.). Now, it seems that it sets the idle period before starting to send keep-alive probes (see here in Go 1.24).

To add to the confusion, the same commit mentioned above apparently changed the meaning of "period" from keep-alive interval period to keep-alive idle period:

Image

My understanding is that to properly set the keep-alive interval period, you would need to use the new KeepAliveConfig where the idle period and the interval can be set separately.

As I said I may be missing some context so forgive me if this isn't entirely accurate, but I thought it could be helpful to raise the doubt.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions