I am trying to upload my images but in some devices I am getting this exception: Cause: java.net.SocketTimeoutException: SSL handshake timed out
Message : SSL handshake timed out
Unable to execute HTTP request: SSL handshake timed out
Exception: com.amazonaws.AmazonClientException: Unable to execute HTTP request: SSL handshake timed out
private fun writeInAws(uri: String): Deferred<String?> {
return async(CommonPool) {
compress(uri)
val AWS_SECRET_KEY = "MY_KEY"
val AWS_ACCESS_KEY = "MY_ACCESS_KEY"
val credentials = BasicAWSCredentials(AWS_ACCESS_KEY, AWS_SECRET_KEY)
val s3 = AmazonS3Client(credentials)
val transferUtility = TransferUtility(s3,this@IdCaptureActivity)
val bucketUrl = getString(R.string.aws_bucket_url)
val bucketName = getString(R.string.aws_bucket_name)
val bucketDirectory = getString(R.string.aws_bucket_directory) + "/" + Utils.getUserPhone(this@IdCaptureActivity)
val observer = transferUtility.upload(
"$bucketName/$bucketDirectory",
getName(uri),
File(uri)
)
observer.setTransferListener(object : TransferListener {
override fun onProgressChanged(id: Int, bytesCurrent: Long, bytesTotal: Long) {
val percentDonef = bytesCurrent.toFloat() / bytesTotal.toFloat() * 100
val percentDone = percentDonef.toInt()
Log.d("MainActivity", " ID:$id bytesCurrent: $bytesCurrent bytesTotal: $bytesTotal $percentDone%")
}
override fun onStateChanged(id: Int, state: TransferState?) {
}
override fun onError(id: Int, ex: Exception?) {
Log.d("writeInAws error", ex.toString())
}
})
val url = "$bucketDirectory/${getName(uri)}"
s3.putObject(bucketName, url, File(uri))
"$bucketUrl/$bucketName/$bucketDirectory/${getName(uri)}"
}
}
Can someone help me? I have been trying a lot of things, but I could not find what is going on!