aws / aws-sdk-js

AWS SDK for JavaScript in the browser and Node.js
https://aws.amazon.com/developer/language/javascript/
Apache License 2.0
7.59k stars 1.55k forks source link

I am unable to initialize aws-sdk in my nestjs application.it is throwing Error: read ECONNRESET #3482

Closed UjjualUSspericorn closed 3 years ago

UjjualUSspericorn commented 3 years ago

Confirm by changing [ ] to [x] below:

I am unable to initialize aws-sdk in my nestjs application.it is throwing Error: read ECONNRESET when below given service code is given

    import {
        Injectable, NotFoundException,
      } from '@nestjs/common';

      import {
        S3
      } from 'aws-sdk';

 @Injectable()
  export class FileUploadService {
    AWS_S3_BUCKET_NAME = 'bucketname';
    AWS_ACCESS_KEY_ID = 'key'; 
    AWS_SECRET_ACCESS_KEY = 'key'; 
    AWS_REGION_ID = 'us-east-2';
    // s3: any = this.getS3();

    async fileupload(files,folderName) {
        console.log(this.AWS_ACCESS_KEY_ID);
        try {
            let s3 = new S3({
                accessKeyId: this.AWS_ACCESS_KEY_ID,
                secretAccessKey: this.AWS_SECRET_ACCESS_KEY,
                region: this.AWS_REGION_ID,
              });

The code freezes at new S3({ ....

Below given are the dependencies used in my nestjs app

 "dependencies": {
"@magna_shogun/catch-decorator": "^1.0.1",
"@nest-toolbox/http-logger-middleware": "^1.1.18",
"@nestjs-modules/mailer": "^1.5.1",
"@nestjs/common": "^7.4.4",
"@nestjs/core": "^7.4.4",
"@nestjs/jwt": "^7.1.0",
"@nestjs/platform-express": "^7.4.4",
"@nestjs/swagger": "^4.6.0",
"@nestjs/typeorm": "^7.1.3",
"@ogma/nestjs-module": "^0.3.1",
"@ogma/platform-express": "^0.3.1",
"@types/bcrypt": "^3.0.0",
"@types/body-parser": "^1.19.0",
"@types/compression": "^1.7.0",
"@types/express-rate-limit": "^5.1.0",
"@types/helmet": "0.0.47",
"@types/jsonwebtoken": "^8.5.0",
"aws-sdk": "^2.767.0",

This feature worked fine on a different test project that lower dependency versions.

"dependencies": {
    "@nestjs/common": "^5.4.0",
    "@nestjs/core": "^5.4.0",
    "aws-sdk": "^2.400.0",
    "multer": "^1.4.1",
    "multer-s3": "^2.9.0",
    "reflect-metadata": "^0.1.12",
    "rimraf": "^2.6.2",
    "rxjs": "^6.2.2",
    "typescript": "^3.0.1"
  },
ajredniwja commented 3 years ago

Hey @UjjualUSspericorn, thanks for the issue, would you able to setup a repository with the issue, I was not able to reproduce this, I followed a third party article to test it found here.

github-actions[bot] commented 3 years ago

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.