RequestTimeout: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.

See original GitHub issue

I’m getting this error once in a while when making a putObject call.

What is the root cause of the error and what’s the best way to avoid it? According to API response looks like this error is non-retryable. Is there a way to configure aws-sdk to make a retry when this type of error happens?

example response: {“message”:“Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.”,“code”:“RequestTimeout”,“time”:“2014-05-21T00:50:25.709Z”,“statusCode”:400,“retryable”:false,“_willRetry”:false}

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:29 (5 by maintainers)

github_iconTop GitHub Comments

11reactions
fikriauliyacommented, Jul 10, 2017

Now I have pinned point the issue on 2.68.0 <=2.67.0 have no problems.

Further investigation:

The release change on 2.68.0 is:

feature: S3: Switches S3 to use signatureVersion “v4” by default. To continue using signatureVersion “v2”, set the signatureVersion: “v2” option in the S3 service client configuration. Presigned URLs will continue using “v2” by default.

Setting signatureVersion to v2 solve this problem: const s3 = new AWS.S3({signatureVersion: 'v2'});

The followings don’t work: const s3 = new AWS.S3(); => RequestTimeout: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed. const s3 = new AWS.S3({signatureVersion:'v4'); => RequestTimeout: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed. const s3 = new AWS.S3({signatureVersion:'v3'); => AccessDenied: Access Denied

11reactions
PeppeL-Gcommented, Oct 1, 2016

I don’t have time to debug this, but I got the error as well. I uploaded a file from a website to my server (Node) using Ajax, and then uploaded it from my serverto S3 with code looking like this:

var stream = fs.createReadStream(pathToFile)

s3.putObject({
    Bucket: bucketName,
    Key: key,
    Body: stream
}, function(err, data){ /* Do stuff... */ })

The funny thing is that it always fails for the first Ajax request I send, but it works for all that comes after. I don’t know if this is a bug in the AWS SDK or the package multer (with express) I use to receive the uploaded file on my server (although I receive the file perfectly well as far as I can tell; it’s saved on my server).

However, when I change my code to:

fs.readFile(pathToFile, function(err, data){
    if(err){
        // Handle fail...
    }else{
        s3.putObject({
            Bucket: bucketName,
            Key: key,
            Body: data
        }, function(err, data){ /* Do stuff... */ })
    }
})

It works for all my Ajax request.

I might have done a mistake somewhere (I’m not an experience Node programmer), but hopefully this will help someone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

You See: Your Socket Connection to the Server Was Not ...
If you get an error that says "your socket connection to the server was not read from or written to within the timeout...
Read more >
amazon s3 upload file time out - Stack Overflow
Error Message : Your socket connection to the server was not read from or written to within the timeout period. Idle connections will...
Read more >
S3 idle connection timeout | AWS re:Post
I have noticed that connection is closed by server after 3 - 5 seconds if it is not used for sending requests to...
Read more >
S3(fix): Remove socket timeout for op to support upload large ...
S3Exception : Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be...
Read more >
Error Responses - Amazon Simple Storage Service
Error Code Description HTTP Status Code AccessControlListNotSupported The bucket does not allow ACLs. 400 Bad Request AccessDenied Access Denied 403 Forbidden BucketAlreadyOwnedByYou 409 Conflict (in all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found