javax.net.ssl.SSLException during Amazon S3 Multipart Upload
Asked Answered
H

1

9

I'm using Simpl3r, a simple high level Android API for robust and resumable multipart file uploads using the Amazon S3 service, to upload media files to my bucket.

On some uploads, I'm getting a SSLException error. Here's the code where the exception is thrown:

(My class is a subclass of an IntentService, as per the Simpl3r example)

@Override
protected void onHandleIntent(Intent intent) {

    String filePath = intent.getStringExtra(ARG_FILE_PATH);
    final String s3ObjectKey = intent.getStringExtra(ARG_OBJECT_KEY);
    File fileToUpload = new File(filePath);
    String s3BucketName = getString(R.string.s3_bucket);

    final String msg = "Uploading " + s3ObjectKey + "...";

    // create a new uploader for this file
    uploader = new Uploader(this, s3Client, s3BucketName, s3ObjectKey, fileToUpload);

    // listen for progress updates and broadcast/notify them appropriately
    uploader.setProgressListener(new UploadProgressListener() {
        @Override
        public void progressChanged(ProgressEvent progressEvent,
                                    long bytesUploaded, int percentUploaded) {

            Notification notification = buildNotification(msg, percentUploaded);
            nm.notify(NOTIFY_ID_UPLOAD, notification);
            broadcastState(s3ObjectKey, percentUploaded, msg);
        }
    });

    // broadcast/notify that our upload is starting
    Notification notification = buildNotification(msg, 0);
    nm.notify(NOTIFY_ID_UPLOAD, notification);
    broadcastState(s3ObjectKey, 0, msg);

    try {
        String s3Location = uploader.start(); // initiate the upload
        broadcastStateDone(s3ObjectKey, s3Location, "File successfully uploaded to " + s3Location);
    } catch (UploadIterruptedException uie) {
        broadcastStateError(s3ObjectKey, "User interrupted");
    } catch (Exception e) {
        e.printStackTrace();
        broadcastStateError(s3ObjectKey, "Error: " + e.getMessage());
    }
}

Here's the stack trace:

04-28 10:18:35.482  28236-28304/org.dornad.s3test I/AmazonHttpClient﹕ Unable to execute HTTP request: Write error: ssl=0x5c7c7760: I/O error during system call, Connection reset by peer
    javax.net.ssl.SSLException: Write error: ssl=0x5c7c7760: I/O error during system call, Connection reset by peer
        at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_write(Native Method)
        at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:706)
        at com.amazonaws.org.apache.http.impl.io.AbstractSessionOutputBuffer.write(AbstractSessionOutputBuffer.java:169)
        at com.amazonaws.org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:119)
        at com.amazonaws.org.apache.http.entity.InputStreamEntity.writeTo(InputStreamEntity.java:102)
        at com.amazonaws.http.RepeatableInputStreamRequestEntity.writeTo(Unknown Source)
        at com.amazonaws.org.apache.http.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:98)
        at com.amazonaws.org.apache.http.impl.client.EntityEnclosingRequestWrapper$EntityWrapper.writeTo(EntityEnclosingRequestWrapper.java:108)
        at com.amazonaws.org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:122)
        at com.amazonaws.org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:271)
        at com.amazonaws.org.apache.http.impl.conn.ManagedClientConnectionImpl.sendRequestEntity(ManagedClientConnectionImpl.java:197)
        at com.amazonaws.org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:257)
        at com.amazonaws.http.protocol.SdkHttpRequestExecutor.doSendRequest(Unknown Source)
        at com.amazonaws.org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
        at com.amazonaws.org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:717)
        at com.amazonaws.org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:522)
        at com.amazonaws.org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
        at com.amazonaws.org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
        at com.amazonaws.http.AmazonHttpClient.executeHelper(Unknown Source)
        at com.amazonaws.http.AmazonHttpClient.execute(Unknown Source)
        at com.amazonaws.services.s3.AmazonS3Client.invoke(Unknown Source)
        at com.amazonaws.services.s3.AmazonS3Client.uploadPart(Unknown Source)
        at com.readystatesoftware.simpl3r.Uploader.start(Uploader.java:162)
        at org.dornad.s3test.service.UploadService.onHandleIntent(UploadService.java:96)
        at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.os.HandlerThread.run(HandlerThread.java:60)

The exception is not caught by my Exception clause. Meaning that the app is stuck in a "uploading" state that never ends.

Any ideas?

Haversack answered 28/4, 2014 at 14:35 Comment(1)
Any update bro ?Nuke
O
0

How long do these uploads take? Could you be getting reset?

Obel answered 22/7, 2015 at 18:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.