You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,6 +158,10 @@ for (BoxItem.Info itemInfo : rootFolder) {
158
158
}
159
159
```
160
160
161
+
> **Important:**`The com.box.sdk package` does **not** apply default connection or read timeouts. Unless you configure them, connection and read timeout values are **`0` milliseconds**, which means the client does not enforce a limit while establishing a connection or while reading the response body.
162
+
163
+
To set connect and read timeouts, follow the instructions in [configuration.md](./docs/sdk/configuration.md#network-timeouts).
164
+
161
165
# Authentication
162
166
163
167
Both the `com.box.sdkgen` and `com.box.sdk` packages support multiple authentication methods, including
The legacy **`com.box.sdk`** package uses OkHttp for HTTP calls. Connect and read timeouts are controlled through [`BoxAPIConnection`](https://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxAPIConnection.html) and [`BoxGlobalSettings`](https://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxGlobalSettings.html).
142
+
143
+
## Default behavior
144
+
145
+
> **Important:** The legacy SDK does **not** apply default connection or read timeouts. Unless you configure them, connection and read timeout values are **`0` milliseconds**, which means the client does not enforce a limit while establishing a connection or while reading the response body.
146
+
147
+
If your application needs bounded network behavior (recommended for production workloads), you **must** set connect and read timeouts explicitly using the options below.
148
+
149
+
## Connection timeout
150
+
151
+
Controls how long the client waits to establish a connection, in milliseconds.
152
+
153
+
There is **no default** connection timeout until you set one.
154
+
155
+
**Per connection** — [`BoxAPIConnection#setConnectTimeout`](https://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxAPIConnection.html#setConnectTimeout-int-) rebuilds the internal HTTP client when called:
156
+
157
+
```java
158
+
BoxAPIConnection api =newBoxAPIConnection("access_token");
159
+
api.setConnectTimeout(30_000); // milliseconds
160
+
```
161
+
162
+
**All new connections** — [`BoxGlobalSettings#setConnectTimeout`](https://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxGlobalSettings.html#setConnectTimeout-int-) applies to connections created after it is set. Configure globals **before** constructing `BoxAPIConnection`:
163
+
164
+
```java
165
+
BoxGlobalSettings.setConnectTimeout(30_000);
166
+
BoxAPIConnection api =newBoxAPIConnection("access_token");
167
+
```
168
+
169
+
## Read timeout
170
+
171
+
Controls how long the client waits for response data while reading from the connection, in milliseconds.
172
+
173
+
There is **no default** read timeout until you set one.
BoxAPIConnection api =newBoxAPIConnection("access_token");
179
+
api.setReadTimeout(60_000); // milliseconds
180
+
```
181
+
182
+
**All new connections** — [`BoxGlobalSettings#setReadTimeout`](https://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxGlobalSettings.html#setReadTimeout-int-):
183
+
184
+
```java
185
+
BoxGlobalSettings.setReadTimeout(60_000);
186
+
BoxAPIConnection api =newBoxAPIConnection("access_token");
187
+
```
188
+
189
+
## Complete example
190
+
191
+
Set both timeouts globally before creating a connection:
192
+
193
+
```java
194
+
BoxGlobalSettings.setConnectTimeout(30_000);
195
+
BoxGlobalSettings.setReadTimeout(60_000);
196
+
197
+
BoxAPIConnection api =newBoxAPIConnection("access_token");
198
+
// api uses 30s connect timeout and 60s read timeout
199
+
```
200
+
201
+
Or set both on a single connection:
202
+
203
+
```java
204
+
BoxAPIConnection api =newBoxAPIConnection("access_token");
205
+
api.setConnectTimeout(30_000);
206
+
api.setReadTimeout(60_000);
207
+
```
208
+
209
+
# Configure retries of calls
210
+
137
211
SDK can retry failed calls when:
138
212
- failed writting request body
139
213
- when recieved HTTP response code:
@@ -157,32 +231,6 @@ api.setMaxRetryAttempts(10);
157
231
158
232
default value for retry attempts is `5`.
159
233
160
-
## Connection timeout
161
-
162
-
To set up how log (in milliseconds) API waits to establish connection
163
-
use [BoxApiConnection.setConnectTimeout](https://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxAPIConnection.html#setConnectTimeout-int-):
164
-
165
-
```java
166
-
// You can use any subclass of BoxAPIConnection
167
-
int connectionTimeout =100; // timeout in milliseconds
168
-
api.setConnectTimeout(connectionTimeout);
169
-
```
170
-
171
-
default value is `0` which mean API waits forever to establish connection.
172
-
173
-
## Read timeout
174
-
175
-
To set up how log (in milliseconds) API waits to read data from connection
176
-
use [BoxApiConnection.setReadTimeout](https://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxAPIConnection.html#setReadTimeout-int-):
177
-
178
-
```java
179
-
// You can use any subclass of BoxAPIConnection
180
-
int readTimeout =100; // timeout in milliseconds
181
-
api.setReadTimeout(readTimeout);
182
-
```
183
-
184
-
default value is `0` which mean API waits forever to read data from connection.
0 commit comments