Amazon S3 AWS 开始给出错误代码 400,原因不明
Amazon S3 AWS starts giving error code 400 for unknown reason
我不确定从什么时候开始,但在我的开发机器上使用 AWS SDK 和 Java 时出现以下错误:
2015-02-24 18:57:05,834 DEBUG ~ Receiving response: HTTP/1.1 400 Bad Request
2015-02-24 18:57:05,834 DEBUG ~ << HTTP/1.1 400 Bad Request
2015-02-24 18:57:05,834 DEBUG ~ << Server: nginx
2015-02-24 18:57:05,834 DEBUG ~ << Date: Tue, 24 Feb 2015 18:57:05 GMT
2015-02-24 18:57:05,834 DEBUG ~ << Content-Type: application/xml
2015-02-24 18:57:05,834 DEBUG ~ << Transfer-Encoding: chunked
2015-02-24 18:57:05,834 DEBUG ~ << Connection: keep-alive
2015-02-24 18:57:05,834 DEBUG ~ << Bucket: "testmedia"
2015-02-24 18:57:05,834 DEBUG ~ << Accept-Ranges: bytes
2015-02-24 18:57:05,834 DEBUG ~ << Age: 0
2015-02-24 18:57:05,834 DEBUG ~ << X-Cache-Hit: No
2015-02-24 18:57:05,835 DEBUG ~ Connection can be kept alive indefinitely
2015-02-24 18:57:05,835 DEBUG ~ << "51[\r][\n]"
2015-02-24 18:57:05,835 DEBUG ~ << "<?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code></Error>"
2015-02-24 18:57:05,835 DEBUG ~ << "[\r][\n]"
2015-02-24 18:57:05,835 DEBUG ~ << "0[\r][\n]"
2015-02-24 18:57:05,835 DEBUG ~ << "[\r][\n]"
2015-02-24 18:57:05,835 DEBUG ~ Connection [id: 8][route: {s}->https://testmedia.xxx] can be kept alive indefinitely
2015-02-24 18:57:05,835 DEBUG ~ Connection released: [id: 8][route: {s}->https://testmedia.xxx][total kept alive: 1; route allocated: 1 of 50; total allocated: 1 of 50]
2015-02-24 18:57:05,836 DEBUG ~ Received error response: com.amazonaws.services.s3.model.AmazonS3Exception: null (Service: null; Status Code: 400; Error Code: InvalidArgument; Request ID: null), S3 Extended Request ID: null
我可以上传文件,所以凭据似乎没问题,但我似乎没有下载它。我正在使用游戏!框架 (1.2.7) 运行 JDK 1.7 和 AWS SDK 1.9.22.
这可能是什么原因?
最近我确实从 JDK 1.6 切换到 1.7,因为 1.6 与 AWS 的签名问题。我(还)没有在我的生产服务器上安装它,所以它可能与 OS X 相关,但在我确定它不会损坏之前不敢将我的代码部署到生产环境中。
(aws-sdk-java/1.9.22 Mac_OS_X/10.10.3 Java_HotSpot(TM)_64-Bit_Server_VM/24.71-b01/1.7.0_71)
[编辑:]
我的 Java 代码:
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setConnectionTimeout(2500);
AmazonS3 conn = new AmazonS3Client(credentials, clientConfig);
conn.setEndpoint(hostUrl);
S3Object object = conn.getObject(new GetObjectRequest(bucket, fileKey));
与CloudStack和SDK版本有关。我降级到 1.8.11,一切正常!
降级到 1.8.x 或使用像这样的 s3signer:
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setSignerOverride("S3SignerType");
看这里:
https://github.com/elastic/elasticsearch-cloud-aws/issues/155
我不确定从什么时候开始,但在我的开发机器上使用 AWS SDK 和 Java 时出现以下错误:
2015-02-24 18:57:05,834 DEBUG ~ Receiving response: HTTP/1.1 400 Bad Request
2015-02-24 18:57:05,834 DEBUG ~ << HTTP/1.1 400 Bad Request
2015-02-24 18:57:05,834 DEBUG ~ << Server: nginx
2015-02-24 18:57:05,834 DEBUG ~ << Date: Tue, 24 Feb 2015 18:57:05 GMT
2015-02-24 18:57:05,834 DEBUG ~ << Content-Type: application/xml
2015-02-24 18:57:05,834 DEBUG ~ << Transfer-Encoding: chunked
2015-02-24 18:57:05,834 DEBUG ~ << Connection: keep-alive
2015-02-24 18:57:05,834 DEBUG ~ << Bucket: "testmedia"
2015-02-24 18:57:05,834 DEBUG ~ << Accept-Ranges: bytes
2015-02-24 18:57:05,834 DEBUG ~ << Age: 0
2015-02-24 18:57:05,834 DEBUG ~ << X-Cache-Hit: No
2015-02-24 18:57:05,835 DEBUG ~ Connection can be kept alive indefinitely
2015-02-24 18:57:05,835 DEBUG ~ << "51[\r][\n]"
2015-02-24 18:57:05,835 DEBUG ~ << "<?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code></Error>"
2015-02-24 18:57:05,835 DEBUG ~ << "[\r][\n]"
2015-02-24 18:57:05,835 DEBUG ~ << "0[\r][\n]"
2015-02-24 18:57:05,835 DEBUG ~ << "[\r][\n]"
2015-02-24 18:57:05,835 DEBUG ~ Connection [id: 8][route: {s}->https://testmedia.xxx] can be kept alive indefinitely
2015-02-24 18:57:05,835 DEBUG ~ Connection released: [id: 8][route: {s}->https://testmedia.xxx][total kept alive: 1; route allocated: 1 of 50; total allocated: 1 of 50]
2015-02-24 18:57:05,836 DEBUG ~ Received error response: com.amazonaws.services.s3.model.AmazonS3Exception: null (Service: null; Status Code: 400; Error Code: InvalidArgument; Request ID: null), S3 Extended Request ID: null
我可以上传文件,所以凭据似乎没问题,但我似乎没有下载它。我正在使用游戏!框架 (1.2.7) 运行 JDK 1.7 和 AWS SDK 1.9.22.
这可能是什么原因?
最近我确实从 JDK 1.6 切换到 1.7,因为 1.6 与 AWS 的签名问题。我(还)没有在我的生产服务器上安装它,所以它可能与 OS X 相关,但在我确定它不会损坏之前不敢将我的代码部署到生产环境中。
(aws-sdk-java/1.9.22 Mac_OS_X/10.10.3 Java_HotSpot(TM)_64-Bit_Server_VM/24.71-b01/1.7.0_71)
[编辑:] 我的 Java 代码:
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setConnectionTimeout(2500);
AmazonS3 conn = new AmazonS3Client(credentials, clientConfig);
conn.setEndpoint(hostUrl);
S3Object object = conn.getObject(new GetObjectRequest(bucket, fileKey));
与CloudStack和SDK版本有关。我降级到 1.8.11,一切正常!
降级到 1.8.x 或使用像这样的 s3signer:
ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setSignerOverride("S3SignerType");
看这里: https://github.com/elastic/elasticsearch-cloud-aws/issues/155