Skip to content

Commit

Permalink
Avoid the issue of connections not being released.
Browse files Browse the repository at this point in the history
When channelizer.supportsIdleMonitor is false, enable TCP Keep-Alive
to avoid the issue of connections not being released.

Enable TCP Keep-Alive to detect if the remote peer is still reachable.
Keep-Alive sends periodic probes to check if the remote peer is still active.
If the remote peer is unreachable, the connection will be closed, preventing resource leaks and avoiding the maintenance of stale connections.
  • Loading branch information
dh-cloud committed Nov 29, 2024
1 parent 038ba3b commit 8ddd859
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ public synchronized CompletableFuture<ServerGremlinExecutor> start() throws Exce

channelizer = createChannelizer(settings);
channelizer.init(serverGremlinExecutor);
// When the channelizer does not support idle monitoring, enable the ChannelOption.SO_KEEPALIVE feature.
if (!channelizer.supportsIdleMonitor()) {
// Enable TCP Keep-Alive to detect if the remote peer is still reachable.
// Keep-Alive sends periodic probes to check if the remote peer is still active.
// If the remote peer is unreachable, the connection will be closed, preventing resource leaks and
// avoiding the maintenance of stale connections.
b.childOption(ChannelOption.SO_KEEPALIVE, true);
}
b.group(bossGroup, workerGroup)
.childHandler(channelizer);
if (isEpollEnabled){
Expand Down

0 comments on commit 8ddd859

Please sign in to comment.