Amazon S3 分段上传期间的 javax.net.ssl.SSLException

Posted

技术标签:

【中文标题】Amazon S3 分段上传期间的 javax.net.ssl.SSLException【英文标题】:javax.net.ssl.SSLException during Amazon S3 Multipart Upload 【发布时间】:2014-06-14 04:00:51 【问题描述】:

我正在使用 Simpl3r a simple high level android API for robust and resumable multipart file uploads using the Amazon S3 service 将媒体文件上传到我的存储桶。

在某些上传时,我收到 SSLException 错误。以下是引发异常的代码:

(根据 Simpl3r 示例,我的类是 IntentService 的子类)

@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());
    

这是堆栈跟踪:

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)

我的 Exception 子句没有捕获到异常。这意味着应用卡在永无止境的“上传”状态。

有什么想法吗?

【问题讨论】:

你找到解决办法了吗? 兄弟有什么更新吗? 【参考方案1】:

这些上传需要多长时间?可以重置吗?

【讨论】:

以上是关于Amazon S3 分段上传期间的 javax.net.ssl.SSLException的主要内容,如果未能解决你的问题,请参考以下文章

从 Apache Spark 分段上传到 Amazon S3

Amazon S3 CORS 标头仅在 OPTIONS(预检)期间显示,而不在 GET 请求期间显示

AWS S3 大文件分片上传

s3cmd - 删除失败的分段上传占用空间并收费

将流数据上传到 Amazon S3

基于浏览器的上传到 Amazon S3?