android-sdk icon indicating copy to clipboard operation
android-sdk copied to clipboard

java.net.ProtocolException 导致了上传失败

Open hkllzh opened this issue 9 years ago • 5 comments

12-08 12:02:08.182 ? W/System.err: java.net.ProtocolException: expected 5940 bytes but received 6325
12-08 12:02:08.192 ? W/System.err:     at okhttp3.internal.http.Http1xStream$FixedLengthSink.write(Http1xStream.java:283)
12-08 12:02:08.192 ? W/System.err:     at okio.RealBufferedSink.flush(RealBufferedSink.java:216)
12-08 12:02:08.192 ? W/System.err:     at okio.ForwardingSink.flush(ForwardingSink.java:39)
12-08 12:02:08.192 ? W/System.err:     at okio.RealBufferedSink.flush(RealBufferedSink.java:218)
12-08 12:02:08.192 ? W/System.err:     at com.qiniu.android.http.CountingRequestBody.writeTo(CountingRequestBody.java:52)
12-08 12:02:08.192 ? W/System.err:     at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:756)
12-08 12:02:08.192 ? W/System.err:     at com.qiniu.android.http.Client$2.intercept(Client.java:83)
12-08 12:02:08.192 ? W/System.err:     at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:733)
12-08 12:02:08.192 ? W/System.err:     at okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:613)
12-08 12:02:08.192 ? W/System.err:     at okhttp3.RealCall.getResponse(RealCall.java:244)
12-08 12:02:08.192 ? W/System.err:     at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:201)
12-08 12:02:08.192 ? W/System.err:     at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163)
12-08 12:02:08.192 ? W/System.err:     at okhttp3.RealCall.access$100(RealCall.java:30)
12-08 12:02:08.192 ? W/System.err:     at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127)
12-08 12:02:08.192 ? W/System.err:     at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
12-08 12:02:08.192 ? W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1115)
12-08 12:02:08.192 ? W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:590)
12-08 12:02:08.192 ? W/System.err:     at java.lang.Thread.run(Thread.java:818)

出现这个错误,导致了上传失败。

hkllzh avatar Dec 08 '16 06:12 hkllzh

您那边使用的SDK版本是多少呢,另外您上传的资源是以FIle形式还是字符串文件路径的形式还是 byte[] 形式呢

kapok-oak avatar Dec 13 '16 10:12 kapok-oak

sorry。我记得反馈了,但是忘了这个事情了。今天看到了BUG列表,才想起。

使用的File形式,sdk 是7.2.3

compile 'com.qiniu:qiniu-android-sdk:7.2.3'

调用的是下面这个API


UploadManager.java

/**
 * 上传文件
 *
 * @param filePath          上传的文件路径
 * @param key               上传文件保存的文件名
 * @param token             上传凭证
 * @param completionHandler 上传完成的后续处理动作
 * @param options           上传数据的可选参数
 */
public void put(String filePath, String key, String token, UpCompletionHandler completionHandler,
                final UploadOptions options) {
    put(new File(filePath), key, token, completionHandler, options);
}

hkllzh avatar Dec 30 '16 01:12 hkllzh

是否方便提供下您的代码,这边测试下

kapok-oak avatar Jan 06 '17 02:01 kapok-oak

不是一个必现的问题。我们测试基本很难发现。 这个日志也是线上使用的用户反馈说不能使用的时候,通过看log截取的。

hkllzh avatar Jan 13 '17 03:01 hkllzh

12-08 12:02:08.182 ? W/System.err: java.net.ProtocolException: expected 5940 bytes but received 6325

这种错误大概是由于回复的 Content-Length 和 实际收到的回复内容字节数量不同导致的。

jemygraw avatar Apr 27 '17 02:04 jemygraw