Repository: aws-amplify/amplify-flutter

Issue #774: Inconsistent Network Timeout between iOS and Android
Created: 2021-08-03T09:35:21Z
I am getting this in the error log-
E/amplify:flutter:storage_s3(23398): StorageException
E/amplify:flutter:storage_s3(23398): StorageException{message=Something went wrong with your AWS S3 Storage upload file operation, cause=com.amazonaws.AmazonClientException: Unable to execute HTTP request: SSL handshake timed out, recoverySuggestion=See attached exception for more information and suggestions}
E/amplify:flutter:storage_s3(23398):    at com.amplifyframework.storage.s3.operation.AWSS3StorageUploadFileOperation$UploadTransferListener.onError(AWSS3StorageUploadFileOperation.java:203)
E/amplify:flutter:storage_s3(23398):    at com.amazonaws.mobileconnectors.s3.transferutility.TransferStatusUpdater$4.run(TransferStatusUpdater.java:306)
E/amplify:flutter:storage_s3(23398):    at android.os.Handler.handleCallback(Handler.java:914)
E/amplify:flutter:storage_s3(23398):    at android.os.Handler.dispatchMessage(Handler.java:100)
E/amplify:flutter:storage_s3(23398):    at android.os.Looper.loop(Looper.java:224)
E/amplify:flutter:storage_s3(23398):    at android.app.ActivityThread.main(ActivityThread.java:7551)
E/amplify:flutter:storage_s3(23398):    at java.lang.reflect.Method.invoke(Native Method)
E/amplify:flutter:storage_s3(23398):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/amplify:flutter:storage_s3(23398):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)
E/amplify:flutter:storage_s3(23398): Caused by: com.amazonaws.AmazonClientException: Unable to execute HTTP request: SSL handshake timed out
E/amplify:flutter:storage_s3(23398):    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:456)
E/amplify:flutter:storage_s3(23398):    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:229)
E/amplify:flutter:storage_s3(23398):    at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4829)
E/amplify:flutter:storage_s3(23398):    at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1912)
E/amplify:flutter:storage_s3(23398):    at com.amazonaws.mobileconnectors.s3.transferutility.UploadTask.uploadSinglePartAndWaitForCompletion(UploadTask.java:282)
E/amplify:flutter:storage_s3(23398):    at com.amazonaws.mobileconnectors.s3.transferutility.UploadTask.call(UploadTask.java:114)
E/amplify:flutter:storage_s3(23398):    at com.amazonaws.mobileconnectors.s3.transferutility.UploadTask.call(UploadTask.java:59)
E/amplify:flutter:storage_s3(23398):    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/amplify:flutter:storage_s3(23398):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/amplify:flutter:storage_s3(23398):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/amplify:flutter:storage_s3(23398):    at java.lang.Thread.run(Thread.java:919)
E/amplify:flutter:storage_s3(23398): Caused by: java.net.SocketTimeoutException: SSL handshake timed out
E/amplify:flutter:storage_s3(23398):    at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
E/amplify:flutter:storage_s3(23398):    at com.android.org.conscrypt.NativeSsl.doHandshake(NativeSsl.java:387)
E/amplify:flutter:storage_s3(23398):    at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:226)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:196)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:153)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:116)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:186)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:302)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:262)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:219)
E/amplify:flutter:storage_s3(23398):    at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:30)
E/amplify:flutter:storage_s3(23398):    at com.amazonaws.http.UrlHttpClient.writeContentToConnection(UrlHttpClient.java:162)
E/amplify:flutter:storage_s3(23398):    at com.amazonaws.http.UrlHttpClient.execute(UrlHttpClient.java:75)
E/amplify:flutter:storage_s3(23398):    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:386)
E/amplify:flutter:storage_s3(23398):    ... 10 more
W/.marketwork.de(23398): Accessing hidden field Lsun/misc/Unsafe;->theUnsafe:Lsun/misc/Unsafe; (greylist, reflection, allowed)
W/.marketwork.de(23398): Accessing hidden method Lsun/misc/Unsafe;->allocateInstance(Ljava/lang/Class;)Ljava/lang/Object; (greylist, reflection, allowed)
I/flutter (23398): UploadFile Err: StorageException(message: Something went wrong with your AWS S3 Storage upload file operation, recoverySuggestion: See attached exception for more information and suggestions, underlyingException: com.amazonaws.AmazonClientException: Unable to execute HTTP request: SSL handshake timed out)
My code
await AmplifyStorageS3.instance.uploadFile(request:UploadFileRequest(local: image, key: imageKey, options: options),);
Platform
Android

Duplicate issue #802: amplify_storage_s3 faces timeout issue for slow internet
Created: 2021-08-12T09:14:02Z
Describe the bug
Basically the storage fails to load the file because of slow internet. As a result the it fails to load the data
To Reproduce
Steps to reproduce the behavior:
After the app starts, the data starts loading and during that time the timeout occurs. Possible reason is due to slow bandwidth.
Expected behavior
The data was supposed to load.
Screenshots
If applicable, add screenshots to help explain your problem.
Platform
Amplify Flutter current supports iOS and Android.  This issue is reproducible in (check all that apply):
[] Android

  LOGCAT
 `
E/amplify:flutter:storage_s3( 9460): StorageException
E/amplify:flutter:storage_s3( 9460): StorageException{message=Something went wrong with your AWS S3 Storage download file operation, cause=com.amazonaws.AmazonClientException: SocketTimeoutException: Unable to retrieve contents over network: timeout, recoverySuggestion=See attached exception for more information and suggestions}
E/amplify:flutter:storage_s3( 9460): 	at com.amplifyframework.storage.s3.operation.AWSS3StorageDownloadFileOperation$DownloadTransferListener.onError(AWSS3StorageDownloadFileOperation.java:191)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.mobileconnectors.s3.transferutility.TransferStatusUpdater$4.run(TransferStatusUpdater.java:306)
E/amplify:flutter:storage_s3( 9460): 	at android.os.Handler.handleCallback(Handler.java:907)
E/amplify:flutter:storage_s3( 9460): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/amplify:flutter:storage_s3( 9460): 	at android.os.Looper.loop(Looper.java:223)
E/amplify:flutter:storage_s3( 9460): 	at android.app.ActivityThread.main(ActivityThread.java:7478)
E/amplify:flutter:storage_s3( 9460): 	at java.lang.reflect.Method.invoke(Native Method)
E/amplify:flutter:storage_s3( 9460): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
E/amplify:flutter:storage_s3( 9460): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
E/amplify:flutter:storage_s3( 9460): Caused by: com.amazonaws.AmazonClientException: SocketTimeoutException: Unable to retrieve contents over network: timeout
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.mobileconnectors.s3.transferutility.DownloadTask.saveToFile(DownloadTask.java:198)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.mobileconnectors.s3.transferutility.DownloadTask.call(DownloadTask.java:111)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.mobileconnectors.s3.transferutility.DownloadTask.call(DownloadTask.java:42)
E/amplify:flutter:storage_s3( 9460): 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/amplify:flutter:storage_s3( 9460): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/amplify:flutter:storage_s3( 9460): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/amplify:flutter:storage_s3( 9460): 	at java.lang.Thread.run(Thread.java:923)
E/amplify:flutter:storage_s3( 9460): Caused by: java.net.SocketTimeoutException: timeout
E/amplify:flutter:storage_s3( 9460): 	at com.android.okhttp.okio.Okio$3.newTimeoutException(Okio.java:214)
E/amplify:flutter:storage_s3( 9460): 	at com.android.okhttp.okio.AsyncTimeout.exit(AsyncTimeout.java:263)
E/amplify:flutter:storage_s3( 9460): 	at com.android.okhttp.okio.AsyncTimeout$2.read(AsyncTimeout.java:217)
E/amplify:flutter:storage_s3( 9460): 	at com.android.okhttp.okio.RealBufferedSource.read(RealBufferedSource.java:51)
E/amplify:flutter:storage_s3( 9460): 	at com.android.okhttp.internal.http.Http1xStream$FixedLengthSource.read(Http1xStream.java:395)
E/amplify:flutter:storage_s3( 9460): 	at com.android.okhttp.okio.RealBufferedSource$1.read(RealBufferedSource.java:372)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:73)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.services.s3.model.S3ObjectInputStream.read(S3ObjectInputStream.java:126)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:73)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:73)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.event.ProgressReportingInputStream.read(ProgressReportingInputStream.java:132)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:73)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.util.LengthCheckInputStream.read(LengthCheckInputStream.java:99)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.internal.SdkFilterInputStream.read(SdkFilterInputStream.java:73)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.services.s3.model.S3ObjectInputStream.read(S3ObjectInputStream.java:126)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.services.s3.model.S3ObjectInputStream.read(S3ObjectInputStream.java:118)
E/amplify:flutter:storage_s3( 9460): 	at com.amazonaws.mobileconnectors.s3.transferutility.DownloadTask.saveToFile(DownloadTask.java:191)
E/amplify:flutter:storage_s3( 9460): 	... 6 more
E/amplify:flutter:storage_s3( 9460): Caused by: java.net.SocketException: Socket closed
E/amplify:flutter:storage_s3( 9460): 	at java.net.SocketInputStream.read(SocketInputStream.java:209)
E/amplify:flutter:storage_s3( 9460): 	at java.net.SocketInputStream.read(SocketInputStream.java:144)
E/amplify:flutter:storage_s3( 9460): 	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.readFromSocket(ConscryptEngineSocket.java:898)
E/amplify:flutter:storage_s3( 9460): 	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.processDataFromSocket(ConscryptEngineSocket.java:862)
E/amplify:flutter:storage_s3( 9460): 	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.readUntilDataAvailable(ConscryptEngineSocket.java:777)
E/amplify:flutter:storage_s3( 9460): 	at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.read(ConscryptEngineSocket.java:750)
E/amplify:flutter:storage_s3( 9460): 	at com.android.okhttp.okio.Okio$2.read(Okio.java:138)
E/amplify:flutter:storage_s3( 9460): 	at com.android.okhttp.okio.AsyncTimeout$2.read(AsyncTimeout.java:213)
E/amplify:flutter:storage_s3( 9460): 	... 20 more
`

Smartphone (please complete the following information):

Device: Pixel 3 API R
OS: Android R

Closing comment (2021-08-12T16:34:02Z): Hello @absarrahman - This looks like a duplicate of #774. Do you mind adding the logs in a comment on that issue so that they can be tracked on one spot? Info about the file size and network bandwidth would be helpful as well.
I am going to close this out as a duplicate.