android-sdk
android-sdk copied to clipboard
java.net.ProtocolException 导致了上传失败
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)
出现这个错误,导致了上传失败。
您那边使用的SDK版本是多少呢,另外您上传的资源是以FIle形式还是字符串文件路径的形式还是 byte[] 形式呢
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);
}
是否方便提供下您的代码,这边测试下
不是一个必现的问题。我们测试基本很难发现。 这个日志也是线上使用的用户反馈说不能使用的时候,通过看log截取的。
12-08 12:02:08.182 ? W/System.err: java.net.ProtocolException: expected 5940 bytes but received 6325
这种错误大概是由于回复的 Content-Length 和 实际收到的回复内容字节数量不同导致的。