Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javax.net.ssl.SSLException: Write error: ssl=0x7f70604080: I/O error during system call, Broken pipe

I use retrofit for uploading image to server, but have a strange issue

api method declaration:

@POST("/uploadImage")
@Multipart
Result<UploadImageResponse> uploadImage(@Part("image") TypedByteArray image);

rest adapter user custom client:

OkClient client = new OkClient(getUnsafeOkHttpClient());

where

private OkHttpClient getUnsafeOkHttpClient() {

    try {
        // Create a trust manager that does not validate certificate chains
        final TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
            @Override
            public void checkClientTrusted(
                    java.security.cert.X509Certificate[] chain,
                    String authType) throws CertificateException {
            }

            @Override
            public void checkServerTrusted(
                    java.security.cert.X509Certificate[] chain,
                    String authType) throws CertificateException {
            }

            @Override
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return null;
            }
        }};

        // Install the all-trusting trust manager
        final SSLContext sslContext = SSLContext.getInstance("SSL");
        sslContext.init(null, trustAllCerts,
                new java.security.SecureRandom());
        // Create an ssl socket factory with our all-trusting manager
        final SSLSocketFactory sslSocketFactory = sslContext
                .getSocketFactory();

        OkHttpClient okHttpClient = new OkHttpClient();
        okHttpClient.setSslSocketFactory(sslSocketFactory);
        okHttpClient.setHostnameVerifier(new HostnameVerifier() {

            @Override
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }
        });

        return okHttpClient;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

exception log:

D/Retrofit: javax.net.ssl.SSLException: Write error: ssl=0x7f70604080: 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 com.squareup.okhttp.internal.http.Http1xStream$FixedLengthSink.write(Http1xStream.java:288)
                                                                   at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
                                                                   at okio.RealBufferedSink$1.write(RealBufferedSink.java:198)
                                                                   at java.io.OutputStream.write(OutputStream.java:82)
                                                                   at retrofit.mime.TypedByteArray.writeTo(TypedByteArray.java:66)
                                                                   at retrofit.client.UrlConnectionClient.prepareRequest(UrlConnectionClient.java:68)
                                                                   at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:37)
                                                                   at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
                                                                   at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
                                                                   at java.lang.reflect.Proxy.invoke(Proxy.java:393)
                                                                   at $Proxy3.uploadImage(Unknown Source)
like image 293
Alex Klimashevsky Avatar asked Jun 24 '16 14:06

Alex Klimashevsky


1 Answers

This exception is the result of file limit on server side

like image 121
Alex Klimashevsky Avatar answered Oct 11 '22 02:10

Alex Klimashevsky