JDK-8194298 : Add support for per Socket configuration of TCP keepalive
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 8,11
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-01-02
  • Updated: 2020-08-13
  • Resolved: 2018-05-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 8 Other
11 b16Fixed 8u261Fixed openjdk8u272Fixed
Related Reports
CSR :  
Duplicate :  
Relates :  
Description
The default idle time for SO_KEEPALIVE is 2 hours, too long for most applications. Some operation systems have support to configure the idle time on a per connection basis (Linux has TCP_KEEPIDLE, Windows has SIO_KEEPALIVE_VALS). We should consider exposing an extended socket option to configure this.
Comments
Fix Request (OpenJDK 8u): Please approve this OpenJDK 8u backport for Oracle JDK 8 parity. The JDK 11 patch doesn't apply at all as this code has been heavily refactored in later JDKs. The JDK 8u patch is basically a rewrite of the original patch with the gist of the changes in ExtendenSocketOptionsImpl.c. This is an implementation for Linux and Mac only (as for the original change). The risk of this patch seems moderate. While it's changing some core net library code, new code paths are only executed when new extended options are being used. Testing: tier1 and java/nio java/net/ jdk/net on Linux. New/modified tests on Mac and Windows. No build breakage observed on Windows. The patch has been reviewed by Andrew Haley and Vyom Tiwari. Webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8194298/jdk8/05/webrev/ RFR: http://mail.openjdk.java.net/pipermail/jdk8u-dev/2020-June/012045.html CSR for JDK 8: JDK-8236187
01-07-2020

[~robm] I see that the JDK 11 change required a CSR. Is there a CSR for JDK 8 as well? Was this backported to JDK 8 without a CSR? It's unclear what the process is WRT backporting and CSRs. Update: Nevermind. Found it: https://bugs.openjdk.java.net/browse/JDK-8236187
16-06-2020

The specific proposal is to add a JDK-specific API, in jdk.net.ExtendedSocketOptions, to support: * TCP_KEEPIDLE, TCP_KEEPCNT, and TCP_KEEPINTVL * on Linux and macOS Other platforms have somewhat limited support for, a subset of, these options. Implementations on other platforms can be added in the future, if needed.
11-04-2018