user1745356
user1745356

Reputation: 4673

java.net.SocketTimeoutException: Read timed out while downloading google spreadsheet

I have a piece of code that downloads google spreadsheet

File file = service.files().get(spreadsheetID).execute();
String downloadUrl = file.getExportLinks().get("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
HttpResponse resp = service.getRequestFactory().buildGetRequest(new GenericUrl(downloadUrl))
                .setConnectTimeout(0).execute();

Connect timeout by default is 20 seconds. I've tried to set it to different values but it doesn't work. I keep getting

Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.7.0_60] at java.net.SocketInputStream.read(SocketInputStream.java:152) ~[na:1.7.0_60] at java.net.SocketInputStream.read(SocketInputStream.java:122) ~[na:1.7.0_60] at sun.security.ssl.InputRecord.readFully(InputRecord.java:442) ~[na:1.7.0_60] at sun.security.ssl.InputRecord.read(InputRecord.java:480) ~[na:1.7.0_60] at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927) ~[na:1.7.0_60] at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:884) ~[na:1.7.0_60] at sun.security.ssl.AppInputStream.read(AppInputStream.java:102) ~[na:1.7.0_60] at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) ~[na:1.7.0_60] at java.io.BufferedInputStream.read1(BufferedInputStream.java:275) ~[na:1.7.0_60] at java.io.BufferedInputStream.read(BufferedInputStream.java:334) ~[na:1.7.0_60] at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687) ~[na:1.7.0_60] at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633) ~[na:1.7.0_60] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1323) ~[na:1.7.0_60] at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468) ~[na:1.7.0_60] at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338) ~[na:1.7.0_60] at com.google.api.client.http.javanet.NetHttpResponse.(NetHttpResponse.java:36) ~[google-http-client-1.19.0.jar:1.19.0] at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:94) ~[google-http-client-1.19.0.jar:1.19.0] at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:965) ~[google-http-client-1.19.0.jar:1.19.0]

Upvotes: 1

Views: 3156

Answers (1)

Zielu
Zielu

Reputation: 8552

you need to setReadTimeout as well probably the document is too large

Upvotes: 3

Related Questions