在使用改装2.0尝试上传大型视频文件(~140mb)时,我在上传之间遇到异常。小文件正在顺利进行。
javax.net.ssl.SSLException: Write error: ssl=0xb924ef28: I/O error during system call, Broken pipe
at com.android.org.conscrypt.NativeCrypto.SSL_write(Native Method)
at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:771)
at okio.Okio$1.write(Okio.java:80)
at okio.AsyncTimeout$1.write(AsyncTimeout.java:155)
at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
at okio.RealBufferedSink.write(RealBufferedSink.java:46)
at okhttp3.internal.http.Http1xStream$FixedLengthSink.write(Http1xStream.java:286)
at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
at okio.RealBufferedSink.writeAll(RealBufferedSink.java:104)
at okhttp3.RequestBody$3.writeTo(RequestBody.java:118)
at okhttp3.MultipartBody.writeOrCountBytes(MultipartBody.java:171)
at okhttp3.MultipartBody.writeTo(MultipartBody.java:113)
at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:704)
at okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:563)
at okhttp3.RealCall.getResponse(RealCall.java:241)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
这是我如何创建多部分/表单数据
File originalFile = new File(attachment.getFilePath());
RequestBody requestFile
= RequestBody.create(MediaType.parse("multipart/form-data"), originalFile);
MultipartBody.Part body
= MultipartBody.Part.createFormData("file", attachment.getUuid(), requestFile);
Call<ResponseBody> call
= FileAPIProvider.getService().upload(attachment.getUuid(),
attachment.getUuid(),
attachment.getMimeType(),
body,
attachment.getVirtualPath());
改装适配器设置
builder.connectTimeout(30, TimeUnit.SECONDS);
builder.readTimeout(60, TimeUnit.MINUTES);
builder.writeTimeout(60, TimeUnit.MINUTES);
// Add headers
builder.interceptors().add(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
String token = LocalStorage.getInstance().getToken();
request = request.newBuilder()
.addHeader("Authorization", token)
.build();
return chain.proceed(request);
}
});
sRetrofit = new Retrofit.Builder()
.baseUrl(BuildConfig.FILE_URL)
.client(builder.build())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();
我很确定我的网络连接足够稳定。