Closed IRus closed 8 years ago
Do you see this error every time you call listBuckets() or occasionally?
Is it possible for you to provide the wire log when this error occurs. Instructions to enable wire logging: https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/java-dg-logging.html
Awww. I found that i inject bean AmazonS3Client instead of AmazonS3 and my DI in this case creates bean via default constructor, so credentials doesn't passed in constructor.
But anyway, error quite strange, amazon returned HTTP 200 OK and HTML page instead of 40x:
2016-10-18 11:36:16,598 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "GET /s3/ HTTP/1.1[\r][\n]"
2016-10-18 11:36:16,598 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "Host: aws.amazon.com[\r][\n]"
2016-10-18 11:36:16,598 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "User-Agent: aws-sdk-java/1.11.43 Linux/4.4.0-43-generic Java_HotSpot(TM)_64-Bit_Server_VM/25.101-b13/1.8.0_101[\r][\n]"
2016-10-18 11:36:16,598 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "amz-sdk-invocation-id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx[\r][\n]"
2016-10-18 11:36:16,598 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "amz-sdk-retry: 1/0/500[\r][\n]"
2016-10-18 11:36:16,598 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "Content-Type: application/octet-stream[\r][\n]"
2016-10-18 11:36:16,598 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "Connection: Keep-Alive[\r][\n]"
2016-10-18 11:36:16,598 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "[\r][\n]"
2016-10-18 11:36:16,855 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "HTTP/1.1 200 OK[\r][\n]"
2016-10-18 11:36:16,856 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Server: Server[\r][\n]"
2016-10-18 11:36:16,856 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Date: Tue, 18 Oct 2016 08:36:16 GMT[\r][\n]"
2016-10-18 11:36:16,856 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Content-Type: text/html;charset=UTF-8[\r][\n]"
2016-10-18 11:36:16,856 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Transfer-Encoding: chunked[\r][\n]"
2016-10-18 11:36:16,859 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Connection: keep-alive[\r][\n]"
2016-10-18 11:36:16,859 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "X-Frame-Options: SAMEORIGIN[\r][\n]"
2016-10-18 11:36:16,859 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "X-Content-Type-Options: nosniff[\r][\n]"
2016-10-18 11:36:16,859 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "x-amz-id-1: xxxxxxxxxxxxxxxxxxxxxxxx[\r][\n]"
2016-10-18 11:36:16,859 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Last-Modified: Fri, 14 Oct 2016 20:21:28 GMT[\r][\n]"
2016-10-18 11:36:16,859 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Vary: Accept-Encoding,User-Agent[\r][\n]"
2016-10-18 11:36:16,859 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Access-Control-Allow-Origin: http://aws.amazon.com[\r][\n]"
2016-10-18 11:36:16,859 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Set-Cookie: aws_lang=en; Domain=.amazon.com; Path=/[\r][\n]"
There are a lot of output, and i'm not sure if it is secure to put it all here.
Don't put any sensitive information here.
1) Do you have any buckets that have Non–DNS-Compliant Bucket Names? https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html 2) How often do you see the error? 3) In the log, you have removed the request ids. Please give me x-amz-request-id and x-amz-id-2 so that service team can look at their logs on why the error happened. This information is not sensitive, so feel free to post it here.
Ah, I'm not native speaker, so looks like you doesn't got what i say :)
0.
Problem caused by not passing credentials nor via ProfileCredentialsProvider
, nor via any other Provider in AWSCredentialsProviderChain
. This is cause of problems with API, after i pass credentials properly - i become able to list buckets, etc. I expected some sort of validation here, but looks like it's not possible because anonymous access existing, and without breaking changes in sdk java api we can't do this.
1.
No, all buckets names valid according documentation.
2.
Every time, when i don't pass credentials :)
3.
"Please give me x-amz-request-id and x-amz-id-2" I doesn't think that this is necessary, because obviously this is problem on my side :)
"Problem caused by not passing credentials nor via ProfileCredentialsProvider, nor via any other Provider in AWSCredentialsProviderChain. This is cause of problems with API, after i pass credentials properly - i become able to list buckets, etc. I expected some sort of validation here, but looks like it's not possible because anonymous access existing, and without breaking changes in sdk java api we can't do this. "
The client builder will give you this validation, it does not fallback to anonymous access. https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3ClientBuilder.java
@shorea i used it :) Problem was in DI, that create instance of AmazonS3
but I injected AmazonS3Client
. And my DI framework (Guice) doesn't found and instance of AmazonS3Client
and silently injected newly created AmazonS3Client
via default constuctor -> in anonymous mode.
Oh I see. Darn you autowire!
You should add IAM role in s3. This will solve your problem
Hi, i tried to list all buckets using
AmazonS3Client
, and run in following error:Dependency: "com.amazonaws:aws-java-sdk-s3:1.11.40"