在我的 Android 应用中,我必须将文件上传到 Google Drive。直到昨天,我在上传时遇到了 0 个问题。一年多来一直运行良好。突然之间,我收到了很多失败的上传。大多数时候我会得到“读取超时”,但偶尔我会得到 java.io.eofexception。一些上传只是延迟了,对于一个小文件来说可能是 20 秒,而不是正常的 2 秒,但大多数情况下它们都失败了。上传一个接一个,每 10 次上传中就有 1 或 2 次出现此问题。
我尝试使用最新的 1.15.0-rc 库、一些较旧的库以及最新的 google-api-services-drive-v2-rev82-1.14.2-beta.jar 库。似乎没有任何帮助。
Google Drive 有问题吗?我检查了状态页面,它没有显示任何问题。
我还创建了一个新的测试项目,它删除了我的所有代码,我使用新代码从媒体商店连续上传 10 个文件作为测试,这个应用程序也有同样的问题。
编辑:我在 3 个不同的网络上进行了测试,它们都产生了相同的行为。
下面是一个例外的例子:
06-28 06:09:12.942: W/HttpTransport(5758): exception thrown while executing request
06-28 06:09:12.942: W/HttpTransport(5758): java.net.SocketTimeoutException: Read timed out
06-28 06:09:12.942: W/HttpTransport(5758): at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_read(Native Method)
06-28 06:09:12.942: W/HttpTransport(5758): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:664)
06-28 06:09:12.942: W/HttpTransport(5758): at libcore.io.Streams.readSingleByte(Streams.java:41)
06-28 06:09:12.942: W/HttpTransport(5758): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:648)
06-28 06:09:12.942: W/HttpTransport(5758): at libcore.io.Streams.readAsciiLine(Streams.java:201)
06-28 06:09:12.942: W/HttpTransport(5758): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
06-28 06:09:12.942: W/HttpTransport(5758): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
06-28 06:09:12.942: W/HttpTransport(5758): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
06-28 06:09:12.942: W/HttpTransport(5758): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
06-28 06:09:12.942: W/HttpTransport(5758): at libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
06-28 06:09:12.942: W/HttpTransport(5758): at com.google.api.client.http.javanet.NetHttpResponse.<init>(NetHttpResponse.java:37)
06-28 06:09:12.942: W/HttpTransport(5758): at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:95)
06-28 06:09:12.942: W/HttpTransport(5758): at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:980)
06-28 06:09:12.942: W/HttpTransport(5758): at com.google.api.client.googleapis.media.MediaHttpUploader.executeCurrentRequest(MediaHttpUploader.java:456)
06-28 06:09:12.942: W/HttpTransport(5758): at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:362)
06-28 06:09:12.942: W/HttpTransport(5758): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:420)
06-28 06:09:12.942: W/HttpTransport(5758): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:345)
06-28 06:09:12.942: W/HttpTransport(5758): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:463)