【问题标题】:java.net.SocketTimeoutException: Read timed out while downloading google spreadsheetjava.net.SocketTimeoutException:下载谷歌电子表格时读取超时
【发布时间】:2015-05-22 17:38:00
【问题描述】:

我有一段代码可以下载谷歌电子表格

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();

默认连接超时为 20 秒。我尝试将其设置为不同的值,但它不起作用。我不断得到

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

【问题讨论】:

    标签: java google-api google-drive-api google-sheets google-spreadsheet-api


    【解决方案1】:

    您还需要设置读取时间 可能文档太大了

    【讨论】:

    • 谢谢。我混淆了连接和读取超时。这解决了我的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-29
    • 2011-07-13
    • 1970-01-01
    • 1970-01-01
    • 2015-10-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多