Skip to content

Add Configurable HTTP Connection and Request Timeouts #629

Description

@frankgiordano

Investigate and implement support for allowing consumers of the Zowe Client Java SDK to configure the HTTP connection and request timeouts used by the underlying Unirest 4.5.1 client.

Currently, the SDK uses an UnirestInstance for HTTP communication and relies on the default timeout configuration provided by Unirest.

Current Unirest Defaults

With Unirest Java 4.5.1, the default timeout configuration is:

Timeout:

Default - Connection timeout - 10 seconds (10,000 ms)

Request timeout - No timeout (infinite)

The connection timeout controls how long Unirest waits to establish a connection with the remote server.

The request timeout controls the overall amount of time allowed for a request to complete.

UnirestInstance Configuration:

The SDK's UnirestInstance can be configured directly through its Config object.

For example:

UnirestInstance unirest = Unirest.spawnInstance();

unirest.config()
.connectTimeout(10_000)
.requestTimeout(60_000);

This would configure: Connection timeout: 10 seconds AND Request timeout: 60 seconds

You could define new Zowe SDK system properties, then explicitly read them with System.getProperty() and apply them to the UnirestInstance.

For instance:

Define Zowe-specific system properties:

-Dzowe.client.connectTimeout=30000
-Dzowe.client.requestTimeout=120000

Then read them:

String connectTimeout = System.getProperty("zowe.client.connectTimeout");
String requestTimeout = System.getProperty("zowe.client.requestTimeout");

and applies them to the UnirestInstance:

if (connectTimeout != null) {
unirest.config().connectTimeout(Integer.parseInt(connectTimeout));
}

if (requestTimeout != null) {
unirest.config().requestTimeout(Integer.parseInt(requestTimeout));
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions