Skip to content

Commit

Permalink
Enable Keep-Alive socket option by default (#2676)
Browse files Browse the repository at this point in the history
Motivation
There are cases where a TCP socket can be disconnected unexpectedly (terminated without adhering to the protocol), and when there is no interaction with the socket, the staleness will not be detected. Its commonly the case where TCP keep-alive is used as a counter measure for such cases, to force the socket to get into the right term state to reflect the actual condition.

Modifications
Changed ST default to always enable Keep-Alive socket option.

Results
Expectation is to always be able to detect stale sockets in the application space, and force streams attached to these socket to react on that condition.
  • Loading branch information
tkountis committed Oct 19, 2023
1 parent 61973fe commit 877c4f7
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import static io.servicetalk.transport.netty.internal.FlushStrategies.defaultFlushStrategy;
import static io.servicetalk.transport.netty.internal.SocketOptionUtils.addOption;
import static java.net.StandardSocketOptions.SO_KEEPALIVE;
import static java.util.Objects.requireNonNull;

/**
Expand All @@ -53,6 +54,7 @@ abstract class AbstractTcpConfig<SslConfigType extends SslConfig> {
private SslConfigType sslConfig;

protected AbstractTcpConfig() {
socketOption(SO_KEEPALIVE, true);
}

protected AbstractTcpConfig(final AbstractTcpConfig<SslConfigType> from) {
Expand Down

0 comments on commit 877c4f7

Please sign in to comment.