上传大于1mb的文件时出现凌空SSL错误(系统调用期间的I / O错误,对等方重置连接)

时间:2017-01-11 09:21:02

标签: android android-volley

我尝试添加重试政策https://stackoverflow.com/a/22169775/2098493

但是当上传的文件大于1mb时,错误仍然存​​在。

 W/System.err: com.android.volley.NoConnectionError: javax.net.ssl.SSLException: Write error: ssl=0xafc3fe00: I/O error during system call, Connection reset by peer
 W/System.err:     at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:151)
 W/System.err:     at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
 W/System.err: Caused by: javax.net.ssl.SSLException: Write error: ssl=0xafc3fe00: I/O error during system call, Connection reset by peer
 W/System.err:     at com.android.org.conscrypt.NativeCrypto.SSL_write(Native Method)
 W/System.err:     at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:765)
 W/System.err:     at com.android.okio.Okio$1.write(Okio.java:70)
 W/System.err:     at com.android.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:116)
 W/System.err:     at com.android.okio.RealBufferedSink.write(RealBufferedSink.java:44)
 W/System.err:     at com.android.okhttp.internal.http.RetryableSink.writeToSocket(RetryableSink.java:77)
 W/System.err:     at com.android.okhttp.internal.http.HttpConnection.writeRequestBody(HttpConnection.java:240)
 W/System.err:     at com.android.okhttp.internal.http.HttpTransport.writeRequestBody(HttpTransport.java:77)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:622)
 W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:388)
 W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:332)
 W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:500)
 W/System.err:     at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
 W/System.err:     at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
 W/System.err:     at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:110)
 W/System.err:     at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:96)

感谢您的建议。

1 个答案:

答案 0 :(得分:0)

解决方案是添加Volley重试策略并确保后端和服务器(nodejs / nginx)最大上传文件大小都正确设置的组合。

//where RETRY_DEFAULT_TIMEOUT_MS = 5000,  RETRY_DEFAULT_MAX_RETRIES = 3, RETRY_DEFAULT_BACKOFF_MULT = 2.0f

    request.setRetryPolicy(new DefaultRetryPolicy(RETRY_DEFAULT_TIMEOUT_MS,
            RETRY_DEFAULT_MAX_RETRIES,
            RETRY_DEFAULT_BACKOFF_MULT));