Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems in accessing S3 object size #2314

Closed
arianaa30 opened this issue Mar 5, 2021 · 2 comments
Closed

Problems in accessing S3 object size #2314

arianaa30 opened this issue Mar 5, 2021 · 2 comments
Labels
closed-for-staleness guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days.

Comments

@arianaa30
Copy link

I'm trying to get and S3 object size via Java AWS SDK (v2.16.11), and send it back via HTTP response (this is all inside a HTTP Server using com.sun.net.httpserver.HttpServer). But it doesn't work and shows me the following debug messages.

What's going wrong here? Am I missing anything?

			AwsBasicCredentials awsCreds = AwsBasicCredentials.create(
					AdapterMain.ACCESS_KEY,
				    AdapterMain.SECRET_KEY);

			s3Client = S3Client.builder().region(region)
										.endpointOverride(URI.create(AdapterMain.S3server))
				                       .credentialsProvider(StaticCredentialsProvider.create(awsCreds))
				                       .build();
						//TODO
						HeadObjectRequest getObjectRequest = HeadObjectRequest.builder()
								.bucket(bucketName).key("FILES/"+getMD5(id)+"/FILES/"+id+"/"+id+".txt").build();

						HeadObjectResponse objectHead = s3Client.headObject(getObjectRequest);
						long size = objectHead.contentLength();
						System.out.println("=================================="+size);
						response=size+"";
						he.sendResponseHeaders(200, response.length());

And here are the logs:

    18:44:14.898 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain - Creating an interceptor chain that will apply interceptors in the following order: [software.amazon.awssdk.core.internal.interceptor.HttpChecksumRequiredInterceptor@62ec69e1, software.amazon.awssdk.awscore.interceptor.HelpfulUnknownHostExceptionInterceptor@1d17dde7, software.amazon.awssdk.services.s3.internal.handlers.EnableChunkedEncodingInterceptor@339b31af, software.amazon.awssdk.services.s3.internal.handlers.DisableDoubleUrlEncodingInterceptor@3d96c2f6, software.amazon.awssdk.services.s3.internal.handlers.EnableTrailingChecksumInterceptor@3cb417c4, software.amazon.awssdk.services.s3.internal.handlers.CreateMultipartUploadRequestInterceptor@1f6f0d50, software.amazon.awssdk.services.s3.internal.handlers.GetObjectInterceptor@7513515b, software.amazon.awssdk.services.s3.internal.handlers.AsyncChecksumValidationInterceptor@7e99ac7d, software.amazon.awssdk.services.s3.internal.handlers.EndpointAddressInterceptor@620f9e5d, software.amazon.awssdk.services.s3.internal.handlers.ExceptionTranslationInterceptor@56d0ac1, software.amazon.awssdk.services.s3.internal.handlers.GetBucketPolicyInterceptor@6a1b0abe, software.amazon.awssdk.services.s3.internal.handlers.PutObjectInterceptor@5952b9c4, software.amazon.awssdk.services.s3.internal.handlers.SyncChecksumValidationInterceptor@473129c5, software.amazon.awssdk.services.s3.internal.handlers.DecodeUrlEncodedResponseInterceptor@2ae718e0, software.amazon.awssdk.services.s3.internal.handlers.CreateBucketInterceptor@181bb9f8]
    18:44:14.939 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain - Interceptor 'software.amazon.awssdk.services.s3.internal.handlers.EndpointAddressInterceptor@620f9e5d' modified the message with its modifyHttpRequest method.
    18:44:14.967 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.request - Sending Request: DefaultSdkHttpFullRequest(httpMethod=HEAD, protocol=https, host=file-store.s3-server.dcstore.company.net, port=443, encodedPath=/FILES/f13e/FILES/id_1234/id_1234.txt, headers=[amz-sdk-invocation-id, User-Agent], queryParameters=[])
    18:44:14.978 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.auth.signer.Aws4Signer - AWS4 String to sign: AWS4-HMAC-SHA256
    20210305T014414Z
    20210305/us-east-1/s3/aws4_request
    9bfed5fd14903f65ac34647985e2c8a4bbe0fbf311982cfbeb2e44b2b58a2390
    18:44:14.991 [HTTP-Dispatcher] WARN software.amazon.awssdk.http.apache.internal.utils.ApacheUtils - NoSuchMethodException was thrown when disabling normalizeUri. This indicates you are using an old version (< 4.5.8) of Apache http client. It is recommended to use http client version >= 4.5.9 to avoid the breaking change introduced in apache client 4.5.7 and the latency in exception handling. See https://github.com/aws/aws-sdk-java/issues/1919 for more information
    18:44:15.098 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory - socket.getSupportedProtocols(): [TLSv1.3, TLSv1.2, TLSv1.1, TLSv1, SSLv3, SSLv2Hello], socket.getEnabledProtocols(): [TLSv1.3, TLSv1.2, TLSv1.1, TLSv1]
    18:44:15.099 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory - TLS protocol enabled for SSL handshake: [TLSv1.2, TLSv1.1, TLSv1, TLSv1.3]
    18:44:15.506 [HTTP-Dispatcher] DEBUG software.amazon.awssdk.http.apache.internal.net.SdkSslSocket - created: file-store.s3-server.dcstore.company.net/10.111.111.20:443
@arianaa30 arianaa30 added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Mar 5, 2021
@debora-ito
Copy link
Member

@arianaa30 there's no error showing in the log snippet, so I'm not sure what is the issue exactly.

You should fix this WARN though:

18:44:14.991 [HTTP-Dispatcher] WARN software.amazon.awssdk.http.apache.internal.utils.ApacheUtils - NoSuchMethodException was thrown when disabling normalizeUri. This indicates you are using an old version (< 4.5.8) of Apache http client. It is recommended to use http client version >= 4.5.9 to avoid the breaking change introduced in apache client 4.5.7 and the latency in exception handling. See aws/aws-sdk-java#1919 for more information

Check the version of org.apache.httpcomponents-httpclient you are using, it should be >= 4.5.9

@debora-ito debora-ito added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. and removed needs-triage This issue or PR still needs to be triaged. labels Mar 6, 2021
@github-actions
Copy link

It looks like this issue hasn’t been active in longer than a week. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please add a comment to prevent automatic closure, or if the issue is already closed please feel free to reopen it.

@github-actions github-actions bot added closing-soon This issue will close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will close in 4 days unless further comments are made. labels Mar 13, 2021
aws-sdk-java-automation added a commit that referenced this issue Jan 5, 2023
…d8aac40f7

Pull request: release <- staging/a213560c-47df-42ff-b898-045d8aac40f7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days.
Projects
None yet
Development

No branches or pull requests

2 participants