@@ -56,6 +56,11 @@ public abstract class RequestOptions {
5656 */
5757 private Boolean requireEncryption ;
5858
59+ /**
60+ * A value to indicate whether we should disable socket keep-alive.
61+ */
62+ private Boolean disableHttpsSocketKeepAlive ;
63+
5964 /**
6065 * Creates an instance of the <code>RequestOptions</code> class.
6166 */
@@ -78,6 +83,7 @@ public RequestOptions(final RequestOptions other) {
7883 this .setMaximumExecutionTimeInMs (other .getMaximumExecutionTimeInMs ());
7984 this .setOperationExpiryTimeInMs (other .getOperationExpiryTimeInMs ());
8085 this .setRequireEncryption (other .requireEncryption ());
86+ this .setDisableHttpsSocketKeepAlive (other .disableHttpsSocketKeepAlive ());
8187 }
8288 }
8389
@@ -100,6 +106,10 @@ protected static void applyBaseDefaultsInternal(final RequestOptions modifiedOpt
100106 if (modifiedOptions .requireEncryption () == null ) {
101107 modifiedOptions .setRequireEncryption (false );
102108 }
109+
110+ if (modifiedOptions .disableHttpsSocketKeepAlive () == null ) {
111+ modifiedOptions .setDisableHttpsSocketKeepAlive (false );
112+ }
103113 }
104114
105115 /**
@@ -132,6 +142,10 @@ protected static void populateRequestOptions(RequestOptions modifiedOptions,
132142 modifiedOptions .setOperationExpiryTimeInMs (new Date ().getTime ()
133143 + modifiedOptions .getMaximumExecutionTimeInMs ());
134144 }
145+
146+ if (modifiedOptions .disableHttpsSocketKeepAlive () == null ) {
147+ modifiedOptions .setDisableHttpsSocketKeepAlive (clientOptions .disableHttpsSocketKeepAlive ());
148+ }
135149 }
136150
137151 /**
@@ -178,18 +192,29 @@ public final LocationMode getLocationMode() {
178192 public Integer getMaximumExecutionTimeInMs () {
179193 return this .maximumExecutionTimeInMs ;
180194 }
181-
195+
182196 /**
183197 * Gets a value to indicate whether all data written and read must be encrypted. Use <code>true</code> to
184198 * encrypt/decrypt data for transactions; otherwise, <code>false</code>. For more
185199 * information about require encryption defaults, see {@link #setRequireEncryption(Boolean)}.
186- *
200+ *
187201 * @return A value to indicate whether all data written and read must be encrypted.
188202 */
189203 public Boolean requireEncryption () {
190204 return this .requireEncryption ;
191205 }
192206
207+ /**
208+ * Gets a value to indicate whether https socket keep-alive should be disabled. Use <code>true</code> to disable
209+ * keep-alive; otherwise, <code>false</code>. For more information about disableHttpsSocketKeepAlive defaults, see
210+ * {@link ServiceClient#getDefaultRequestOptions()}
211+ *
212+ * @return A value to indicate whther https socket keep-alive should be disabled.
213+ */
214+ public Boolean disableHttpsSocketKeepAlive () {
215+ return this .disableHttpsSocketKeepAlive ;
216+ }
217+
193218 /**
194219 * RESERVED FOR INTERNAL USE.
195220 *
@@ -283,8 +308,8 @@ public void setMaximumExecutionTimeInMs(Integer maximumExecutionTimeInMs) {
283308 * <p>
284309 * The default is set in the client and is by default false, indicating encryption is not required. You can change
285310 * the value on this request by setting this property. You can also change the value on the
286- * {@link ServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via the service
287- * client will use the appropriate value.
311+ * {@link ServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via the
312+ * service client will use the appropriate value.
288313 *
289314 * @param requireEncryption
290315 * A value to indicate whether all data written and read must be encrypted.
@@ -293,6 +318,28 @@ public void setRequireEncryption(Boolean requireEncryption) {
293318 this .requireEncryption = requireEncryption ;
294319 }
295320
321+ /**
322+ * Sets a value to indicate whether https socket keep-alive should be disabled. Use <code>true</code> to disable
323+ * keep-alive; otherwise, <code>false</code>
324+ * <p>
325+ * The default is set in the client and is by default false, indicating that https socket keep-alive will be
326+ * enabled. You can change the value on this request by setting this property. You can also change the value on
327+ * on the {@link ServiceClient#getDefaultRequestOptions()} object so that all subsequent requests made via the
328+ * service client will use the appropriate value.
329+ * <p>
330+ * Setting keep-alive on https sockets is to work around a bug in the JVM where connection timeouts are not honored
331+ * on retried requests. In those cases, we use socket keep-alive as a fallback. Unfortunately, the timeout value
332+ * must be taken from a JVM property rather than configured locally. Therefore, in rare cases the JVM has configured
333+ * aggressively short keep-alive times, it may be beneficial to disable the use of keep-alives lest they interfere
334+ * with long running data transfer operations.
335+ *
336+ * @param disableHttpsSocketKeepAlive
337+ * A value to indicate whether https socket keep-alive should be disabled.
338+ */
339+ public void setDisableHttpsSocketKeepAlive (Boolean disableHttpsSocketKeepAlive ) {
340+ this .disableHttpsSocketKeepAlive = disableHttpsSocketKeepAlive ;
341+ }
342+
296343 /**
297344 * RESERVED FOR INTERNAL USE.
298345 *
0 commit comments