• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Java SDK)
  4. Initialization
  5. Configuring an Instance of ObsClient

Configuring an Instance of ObsClient

You can use the ObsConfiguration configuration class to configure an instance of ObsClient, including the proxy, connection timeout period, maximum number of retry attempts, and other parameters listed in the following table.

Parameter

Description

Method

Recommended Value

connectionTimeout

Timeout period for establishing an HTTP/HTTPS connection, in ms. The default value is 60,000.

ObsConfiguration.setConnectionTimeout

[10000, 60000]

connectionRequestTimeout

Timeout period for obtaining a connection from the connection pool, in ms. By default, connection obtaining will not time out.

ObsConfiguration.setConnectionRequestTimeout

Default

socketTimeout

Timeout duration for transmitting data at the Socket layer, in ms. The default value is 60,000.

ObsConfiguration.setSocketTimeout

[10000, 60000]

idleConnectionTime

Connection idle time, in ms. If a connection exceeds the specified value, the connection will be closed. The default value is 30,000.

ObsConfiguration.setIdleConnectionTime

Default

maxConnections

Maximum number of concurrently opened HTTP connections. The default value is 1000.

ObsConfiguration.setMaxConnections

Default

maxErrorRetry

Maximum number of retry attempts (caused by abnormal requests, 500 errors, and 503 errors) The default value is 3.

ObsConfiguration.setMaxErrorRetry

[1, 5]

endPoint

Endpoint for accessing OBS.

ObsConfiguration.setEndPoint

N/A

endpointHttpPort

Port number used in an HTTP request. The default value is 80.

ObsConfiguration.setEndpointHttpPort

N/A

endpointHttpsPort

Port number used in an HTTPS request. The default value is 443.

ObsConfiguration.setEndpointHttpsPort

N/A

httpsOnly

Whether to access OBS over HTTPS. The default value is true.

ObsConfiguration.setHttpsOnly

Default

httpProxy

HTTP proxy configuration. This parameter is left blank by default.

ObsConfiguration.setHttpProxy

N/A

validateCertificate

Whether to verify the server certificate. The default value is false.

ObsConfiguration.setValidateCertificate

N/A

verifyResponseContentType

Whether to verify ContentType of the response header. The default value is true.

ObsConfiguration.setVerifyResponseContentType

Default

uploadStreamRetryBufferSize

Size of the cache used for uploading a stream object, in bytes. The default size is 512 KB.

ObsConfiguration.setUploadStreamRetryBufferSize

N/A

isNio

Whether to enable the NIO mode. The default value is false.

ObsConfiguration.enableNio, ObsConfiguration.disableNio

N/A

socketWriteBufferSize

Buffer size for sending a socket, in bytes. This parameter corresponds to java.net.SocketOptions.SO_SNDBUF. The default value is -1, which indicates no limitation.

ObsConfiguration.setSocketWriteBufferSize

Default

socketReadBufferSize

Buffer size for receiving a socket, in bytes. This parameter corresponds to java.net.SocketOptions.SO_RCVBUF. The default value is -1, which indicates no limitation.

ObsConfiguration.setSocketReadBufferSize

Default

readBufferSize

Read cache size used for uploading an object to the socket stream, in bytes. The default value is 8192 bytes.

ObsConfiguration.setReadBufferSize

Default

writeBufferSize

Write cache size used for uploading an object to the socket stream, in bytes. The default value is 8192 bytes.

ObsConfiguration.setWriteBufferSize

Default

NOTE:
  • Parameters whose recommended value is N/A need to be set according to the actual conditions.
  • To improve concurrency performance, enable the NIO mode.
  • To improve the upload and download performance of large files in the case that the network bandwidth meets the requirements, you can tune the socketWriteBufferSize, sockeReadBufferSize, readBufferSize, and writeBufferSize parameters.
  • If the network is unstable, you are advised to set larger values for connectionTimeout and socketTimeout.