Skip to content

got "Error: read ECONNRESET at TLSWrap.onStreamRead" when uploading file to s3 bucket of Asia Pacific (Mumbai)  #4045

@zenghj

Description

@zenghj

Checkboxes for prior research

Describe the bug

Fail to upload file to s3 bucket. It seems to be related to the bucket region. With the same code, uploading to bucket of Asia Pacific (Mumbai) (region: ap-south-1) will get the error, but uploading to bucket of Europe (London) (region: eu-west-2) or bucket of EU (London) (region: eu-west-2) will be successfully.

SDK version number

3.186.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.6.0

Reproduction Steps

// // Import required AWS SDK clients and commands for Node.js.
const { PutObjectCommand, S3Client } = require( "@aws-sdk/client-s3");
// // import { s3Client } from "./libs/s3Client.js"; // Helper function that creates an Amazon S3 service client module.
const fs = require('fs')
const path = require('path')

s3Client = new S3Client({
  region: 'ap-south-1',
  credentials: {
    accessKeyId: 'xxxxxx',
    secretAccessKey: 'xxxx'
  }
})

const fileStream = fs.createReadStream('/path-to-my-local-file/test.txt');

// Set the parameters
 const uploadParams = {
  Bucket: 'my-bucket-name',
  // Add the required 'Key' parameter using the 'path' module.
  Key: 'test.txt',
  // Add the required 'Body' parameter
  Body: fileStream,
};


// Upload file to specified bucket.
 const run = async () => {
  try {
    const data = await s3Client.send(new PutObjectCommand(uploadParams));
    console.log("Success", data);
    return data; // For unit tests.
  } catch (err) {
    console.log("Error", err);
  }
};
run();

Observed Behavior

got error:

Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read',
  name: 'TimeoutError',
  '$metadata': { attempts: 3, totalRetryDelay: 478 }
}

Expected Behavior

upload file successfully

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Labels

bugThis issue is a bug.response-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions