# S3, Serverless Framework, Java - Unable to execute HTTP request:Read timed out

**URL:** <https://forum.serverless.com/t/s3-serverless-framework-java-unable-to-execute-http-request-read-timed-out/16695>\
**Category:** Serverless Framework\
**Tags:** aws, lambda\
**Created:** [February 10, 2022, 3:40pm UTC](https://forum.serverless.com/t/s3-serverless-framework-java-unable-to-execute-http-request-read-timed-out/16695 "2022-02-10T15:40:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mauri.pardo](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@mauri.pardo](https://forum.serverless.com/u/mauri.pardo)\
**Post date:** [February 10, 2022, 3:40pm UTC](https://forum.serverless.com/t/s3-serverless-framework-java-unable-to-execute-http-request-read-timed-out/16695/1 "2022-02-10T15:40:02Z")

</div>

I have a Aws lambda that try to access to S3 bucket to get head object and then their metadata.  
I am using Serverless to test locally.  
But, when I execute locally the test, i get:

```auto
software.amazon.awssdk.core.exception.SdkClientException: Unable to execute HTTP request: Read timed

```

If I implemented the lambda with node js, then it work fine. But I need to use Java.

Technologies:

- Java8
- software.amazon.awssdk:bom:2.17.103
- software.amazon.awssdk:lambda
- software.amazon.awssdk:s3
- “serverless”: “^2.71.0”
- “serverless-offline”: “^8.4.0”
- “serverless-s3-local”: “^0.6.21”

Environment:

- Local
- I don’t have VPC

Code:

```auto
public class FileS3Handler implements RequestHandler<Map<String,String>, String> {

    @Override
    public String handleRequest(Map<String,String> event, Context context)
    {
        String response;
       
        URI uri = new URI("http://localhost:3333");

        S3Configuration config = S3Configuration.builder()
                .pathStyleAccessEnabled(true)
                .build();

        S3Client s3Client = S3Client.builder()
                .endpointOverride(uri)
                .serviceConfiguration(config)
                .build();

        HeadObjectRequest headObjectRequest = HeadObjectRequest.builder()
                .bucket("myBucket")
                .key("myFile")
                .build();
            s3Client.
        HeadObjectResponse headObjectResponse = s3Client.headObject(headObjectRequest);

        response = "Metadata: "+ headObjectResponse.metadata().toString();

        return response;
    }
}

```

Environment Variables:

```auto
AWS_ACCESS_KEY_ID=S3RVER
AWS_SECRET_ACCESS_KEY=S3RVER
AWS_REGION=us-west-2

```

serverless.yml

```auto
service: example

provider:
  name: aws
  region: us-west-2
  runtime: java8
  lambdaHashingVersion: 20201221

package:
  individually: true

functions:

  file-handler:
    handler: com.example.FileS3Handler
    events:
      - http:
          path: /api/filetest
          method: get
    package:
      artifact: build/example.zip

plugins:
  - serverless-offline
  - serverless-dotenv-plugin
  - serverless-s3-local

custom:
  serverless-offline:
    httpPort: 4000
  s3:
    port: 3333
    host: localhost

resources:
  Resources:
    Bucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: myBucket

```

Test:

1. Run: serverless start offline
2. Postman → GET [http://localhost:4000/dev/api/filetest](http://localhost:4000/dev/api/filetest)

Does anyone know what is happening?  
Thanks!
