-
Notifications
You must be signed in to change notification settings - Fork 727
Open
Labels
api: driveIssues related to the Drive API API.Issues related to the Drive API API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: docsImprovement to the documentation for an API.Improvement to the documentation for an API.
Description
Environment details
- Specify the API at the beginning of the title. For example, "BigQuery: ...").
General, Core, and Other are also allowed as types - OS type and version: Linux tux 6.12.39-1-MANJARO
- Java version: openjdk 21.0.8 2025-07-15
- version(s): google-api-services-drive v3-rev20250723-2.0.0
Steps to reproduce
- create batch request with ~20 Drive Permission creating request
- sometimes get
java.net.SocketTimeoutException : Read timed out
Code example
BatchRequest batch = service.batch();
// write instead ↓
BatchRequest batch = service.batch(new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) throws IOException {
requestInitializer.initialize(request);
request.setConnectTimeout(3 * 60_000);
request.setReadTimeout(3 * 60_000);
}
});
Stack trace
java.net.SocketTimeoutException: Read timed out
at java.base/sun.nio.ch.NioSocketImpl.timedRead(NioSocketImpl.java:278)
at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:304)
at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:346)
at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:796)
at java.base/java.net.Socket$SocketInputStream.read(Socket.java:1099)
at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:489)
at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:483)
at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:70)
at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1461)
at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:1066)
at java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:291)
at java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:347)
at java.base/java.io.BufferedInputStream.implRead(BufferedInputStream.java:420)
at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:399)
at java.base/sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:827)
at java.base/sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:759)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1706)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1615)
at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:531)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:307)
at com.google.api.client.http.javanet.NetHttpResponse.<init>(NetHttpResponse.java:36)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:152)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:84)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1012)
at com.google.api.client.googleapis.batch.BatchRequest.execute(BatchRequest.java:257)
External references such as API reference guides
- https://developers.google.com/api-client-library/java/google-api-java-client/errors
- https://stackoverflow.com/questions/31312692/change-read-timeout-for-a-batch-http-request-on-using-google-api-client-library?rq=4
similar problem
Any additional information below
When searching for the error you find following docu https://developers.google.com/api-client-library/java/google-api-java-client/errors . Sadly it does not mention that you need to set the HttpRequestInitializer
timeout for batch requests separately.
The default timeout seems very low (20s), so increasing it for batch requests is almost a must.
It would save a lot of time if either the default would be higher, but it would suffice if one could find the solution when searching for the error/exception.
As you can see, the stackoverflow post is from 2015, so nothing new.
Metadata
Metadata
Assignees
Labels
api: driveIssues related to the Drive API API.Issues related to the Drive API API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: docsImprovement to the documentation for an API.Improvement to the documentation for an API.