Hot questions for Handling SSLException in Retrofit

Top 10 Java Open Source / Retrofit / Handling SSLException Write error: ssl=0x7f70604080: I/O error during system call, Broken pipe

Question: I use retrofit for uploading image to server, but have a strange issu

api method declaration:

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

rest adapter user custom client:

OkClient client = new OkClient(getUnsafeOkHttpClient());


private OkHttpClient getUnsafeOkHttpClient() {

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

            public void checkServerTrusted(
          [] chain,
                    String authType) throws CertificateException {

            public[] getAcceptedIssuers() {
                return null;

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

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

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

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

exception log:

D/Retrofit: Write error: ssl=0x7f70604080: I/O error during system call, Broken pipe
at Method)
at okio.Okio$1.write(
at okio.AsyncTimeout$1.write(
at okio.RealBufferedSink.emitCompleteSegments(
at okio.RealBufferedSink.write(
at com.squareup.okhttp.internal.http.Http1xStream$FixedLengthSink.write(
at okio.RealBufferedSink.emitCompleteSegments(
at okio.RealBufferedSink$1.write(
at retrofit.mime.TypedByteArray.writeTo(
at retrofit.client.UrlConnectionClient.prepareRequest(
at retrofit.client.UrlConnectionClient.execute(
at retrofit.RestAdapter$RestHandler.invokeRequest(
at retrofit.RestAdapter$RestHandler.invoke(
at java.lang.reflect.Proxy.invoke(
at $Proxy3.uploadImage(Unknown Source)

Answer: This exception is the result of file limit on server side

Apache has max file upload size. If you try to upload bigger file you will have this exception