Skip to content

Commit cfc508d

Browse files
ludochgae-java-bot
authored andcommitted
Set API host idle timeout to 25 seconds by default instead of no timeout. See jetty/jetty.project#3891
PiperOrigin-RevId: 731360214 Change-Id: Ifedd44381e45a318ab38705d910ba3f41317ee79
1 parent 35aa4e9 commit cfc508d

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/http/JettyHttpApiHostClient.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ private JettyHttpApiHostClient(String url, HttpClient httpClient, Config config)
7272
static JettyHttpApiHostClient create(String url, Config config) {
7373
Preconditions.checkNotNull(url);
7474
HttpClient httpClient = new HttpClient();
75+
long idleTimeout = 25000; // 25 seconds, should be less than 30 or 60 used server-side.
76+
String envValue = System.getenv("APPENGINE_API_CALLS_IDLE_TIMEOUT_MS");
77+
if (envValue != null) {
78+
try {
79+
idleTimeout = Long.parseLong(envValue);
80+
} catch (NumberFormatException e) {
81+
logger.atWarning().withCause(e).log("Invalid idle timeout value: %s", envValue);
82+
}
83+
}
84+
httpClient.setIdleTimeout(idleTimeout);
7585
String schedulerName =
7686
HttpClient.class.getSimpleName() + "@" + httpClient.hashCode() + "-scheduler";
7787
ClassLoader myLoader = JettyHttpApiHostClient.class.getClassLoader();

runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/http/JettyHttpApiHostClient.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ private JettyHttpApiHostClient(String url, HttpClient httpClient, Config config)
7272
static JettyHttpApiHostClient create(String url, Config config) {
7373
Preconditions.checkNotNull(url);
7474
HttpClient httpClient = new HttpClient();
75+
long idleTimeout = 25000; // 25 seconds, should be less than 30 or 60 used server-side.
76+
String envValue = System.getenv("APPENGINE_API_CALLS_IDLE_TIMEOUT_MS");
77+
if (envValue != null) {
78+
try {
79+
idleTimeout = Long.parseLong(envValue);
80+
} catch (NumberFormatException e) {
81+
logger.atWarning().withCause(e).log("Invalid idle timeout value: %s", envValue);
82+
}
83+
}
84+
httpClient.setIdleTimeout(idleTimeout);
7585
String schedulerName =
7686
HttpClient.class.getSimpleName() + "@" + httpClient.hashCode() + "-scheduler";
7787
ClassLoader myLoader = JettyHttpApiHostClient.class.getClassLoader();

0 commit comments

Comments
 (0)