Note that there are some explanatory texts on larger screens.

plurals
  1. POAWS S3 Java SDK: detect time/clock skew programmatically?
    primarykey
    data
    text
    <p>My Android app uses the AWS Java SDK for uploading user photos to S3.</p> <p>Whenever a user's phone's clock is 'skewed', this causes all transfers to fail. This is a well documented aspect of S3:</p> <p><a href="http://aws.amazon.com/articles/1109?_encoding=UTF8&amp;jiveRedirect=1#04" rel="nofollow">http://aws.amazon.com/articles/1109?_encoding=UTF8&amp;jiveRedirect=1#04</a></p> <p>It appears that the upstream S3 service reports this error quite clearly:</p> <blockquote> <p>HTTP Status Code: 403 Forbidden</p> <p>Error Code: RequestTimeToo-Skewed</p> <p>Description: The difference between the request time and the server's time is too large.</p> </blockquote> <p>However when using the Java SDK, it seems as if the informative 403 code is lost ... and I have only an opaque "TransferState.Failed" to go by (which incidentally is the same error if internet connectivity is lost, if it times out, etc...). </p> <p>As far as I can tell from the docs:</p> <p><a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/index.html" rel="nofollow">http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/index.html</a> <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/TransferProgress.html" rel="nofollow">http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/TransferProgress.html</a> <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/Transfer.TransferState.html" rel="nofollow">http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/Transfer.TransferState.html</a> <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/Upload.html" rel="nofollow">http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/Upload.html</a></p> <p>There is no way to get the additional "RequestTimeToo-Skewed" metadata about a transfer failure.</p> <p>Am I missing it? Is there any way to get additional error information when an S3 transfer fails using Amazon's Java SDK?</p> <p><strong>UPDATE #1:</strong> A commenter kindly highlighted that I should clarity two points:</p> <ul> <li>I am actually using the AWS SDK for Android (which seems very similar to the Java SDK, but is nonetheless distinct)</li> <li>I am using the TransferManager class to perform my upload. Apparently, this is a high-level class that wraps the lower-level AmazonS3Client ... and this lower-level class should expose the error reporting I need, but I am still investigating the exact tradeoffs involved between TransferManager and AmazonS3Client. As far as I can tell, there is no way to get progress information via the (synchronous) AmazonS3Client.putObjectRequest which would be a blocker for me...</li> </ul> <p><strong>UPDATE #2:</strong> My sincere thanks to Jason (of the AWS SDK team) for stopping by and helping me out here. The important information is, indeed, available as properties on an AmazonS3Exception if you use certain methods. The docs had originally confused me and I thought that a manual Thread.sleep() loop was required to poll status (and thus I could not leverage waitForCompletion or waitForException), but if you use ProgressListener on PutObjectRequest you can get full progress callbacks and the error-fidelity of AmazonS3Exception. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload