SocketTimeoutException:插入到Google云端硬盘时读取超时 - 是否可重试? [英] SocketTimeoutException: Read timed out on Insert to Google Drive - is it retryable?

查看:223
本文介绍了SocketTimeoutException:插入到Google云端硬盘时读取超时 - 是否可重试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似于 Java Google Drive SDK SocketTimeoutException on File.insert .execute

一个接一个地上传数千个文件,似乎每50个文件中的每一个都会抛出

Uploading thousands of files, one after the other, seems every 1 out of 50 files throws

java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:152)
        at java.net.SocketInputStream.read(SocketInputStream.java:122)
        at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)
        at sun.security.ssl.InputRecord.read(InputRecord.java:480)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
        at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:884)
        at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
        at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1323)
        at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
        at com.google.api.client.http.javanet.NetHttpResponse.<init>(NetHttpResponse.java:36)
        at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:94)
        at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:965)
        at com.google.api.client.googleapis.media.MediaHttpUploader.executeCurrentRequestWithoutGZip(MediaHttpUploader.java:545)
        at com.google.api.client.googleapis.media.MediaHttpUploader.executeCurrentRequest(MediaHttpUploader.java:562)
        at com.google.api.client.googleapis.media.MediaHttpUploader.executeUploadInitiation(MediaHttpUploader.java:519)
        at com.google.api.client.googleapis.media.MediaHttpUploader.resumableUpload(MediaHttpUploader.java:384)
        at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:336)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:418)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
...

文件().insert()。execute()

我不知道这是什么意思是我得到这个异常插入文件

I'm not sure what it "means" that I'm getting this Exception when inserting a file.


  1. 这是否意味着插入请求没有实现,或者不一定?

  2. 意味着客户端在发送插入请求后没有从Google服务器收到回复?

  3. 我应该如何执行指数退避并重试当我收到这个错误?

  1. Does it mean the insert request was not fulfilled, or not necessarily?
  2. Does it simply mean the client did not hear back from the Google servers after it sent the insert request?
  3. Should I be doing exponential back-off and retry when I get this error?


推荐答案

明显的做法是尝试防止超时。我认为没有办法确定插入文件完成之前或之后是否发生错误。当Drive基础架构内部超时时,得到501响应是很常见的,但是您的情况不同。唯一可以确定的方法是在文件对象上设置一个私有属性,然后搜索Drive以查看是否存在该属性的文件(例如mygeneratedId = some_random_UUID)。

The obvious thing to do is to try to prevent the timeout. I don't think there is any way to be sure if the error occurred before or after the insert post was completed. It's quite common to get 501 responses when there are internal timeouts within the Drive infrastructure, but your case is different. The only way to be sure is to set a private property on the file object, and then search Drive to see if a file with that property exists (eg. mygeneratedId = some_random_UUID).

如果您同时插入数千个文件,可以想象您会窒息一些资源(套接字,带宽等)。您可能想尝试稍微调节输入。

If you're inserting thousands of files simultaneously, it's conceivable that you are choking some resource (sockets, bandwidth, etc). You might want to try throttling your inputs slightly.

这篇关于SocketTimeoutException:插入到Google云端硬盘时读取超时 - 是否可重试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆