Error: read ECONNRESET at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27) Uploading the files to store i S3
Asked Answered
C

6

7

When i am trying to upload the file and store in to s3 location, I got the error

    Error: read ECONNRESET
        at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)

is the above a version problem or bug?

    var express = require('express'), 
        aws = require('aws-sdk'),
        bodyParser = require('body-parser'),
        multer = require('multer'),
        multerS3 = require('multer-s3');
    
    aws.config.update({
        secretAccessKey: 'xxxxxxxxxxxxxxxxxxxxxxxxx',
        accessKeyId: 'xxxxxxxxxxxxxxxx',
        region: 'us-east-1'
    });
    
    var app = express(),
        s3 = new aws.S3();
    
    app.use(bodyParser.json());
    
    var upload = multer({
        storage: multerS3({
            s3: s3,
            bucket: 'xxxxx',
            key: function (req, file, cb) {
                console.log(file);
                cb(null, file.originalname); //use Date.now() for unique file keys
            }
        })
    });
    
    //open in browser to see upload form
    app.get('/', function (req, res) {
        res.sendFile(__dirname + '/index.html');
    });
    
    //used by upload form
    app.post('/upload', upload.array('upl',1), function (req, res, next) {
        res.send("Uploaded!");
    });
    
    app.listen(3000, function () {
        console.log('Example app listening on port 3000!');
    });

and index html file

    <form method="post" enctype="multipart/form-data" action="/upload">
            <input type="file" name="upl"/>
            <input type="submit"/>
    </form>

and packages version

      "dependencies": {
        "aws-sdk": "^2.753.0",
        "body-parser": "^1.19.0",
        "express": "^4.17.1",
        "multer": "^1.4.2",
        "multer-s3": "^2.9.0"
      }

and my node and npm versionn is

node is :12.16.1 npm is: 6.13.4

Please any one solve this problem...

Convenience answered 16/9, 2020 at 0:14 Comment(0)
F
1

I was also facing this issue and after doing lots of analysis, I found that it is happening because of Antivirus installed on my machine. Particularly due to Sophos. You can find this issue at - https://community.sophos.com/intercept-x-endpoint/f/discussions/134136/sophos-network-threat-detection-is-blocking-cypress-automation-tool

To solve this issue, try to execute your test cases on Electron browser, or contact your admin team and get the password of Sophos and then Login into the Sophos, Go to settings and disable 'Network Threat Protection

Filterable answered 6/6, 2022 at 11:2 Comment(0)
A
0

This issue may be related to this bug in NodeJS. One thing you can try is putting res.end(); after your res.sendFile(...) and res.send(...) calls. If that doesn't work, you may need to implement a function to call on a process uncaughtException, or wait to see how the Node community ends up working around the issue.

Apodal answered 30/9, 2020 at 14:16 Comment(0)
G
0

I had a similar issue using Node 16.7.0:

Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:220:20) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read'
}

I was able to solve it by adding req.end() after checking for the 'error' event.

Gerfen answered 24/11, 2021 at 1:37 Comment(0)
M
0

I had the same issue when trying to run 'npm install' in an Angular project using the node version 16.13.2.

When I switched the node version to 12.18.1 I was able to run the command with no problems.

Marna answered 18/7, 2022 at 16:44 Comment(0)
R
0

Dont you have a crazy docker instance that is crashing and restarting on a loop ? Sometime it make cause random connection reset.

Replicate answered 22/9, 2022 at 7:42 Comment(0)
C
0

#Error: read ECONNRESET

I had this issue in my Nextjs app, the solution was to update node to LTS 18.x.x and node version to 9.9

Craniometer answered 11/10, 2023 at 20:16 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.