错误:在TLSWrap.onStreamRead读取ECONNRESET(internal/stream_base_co



当我试图上传文件并存储到s3位置时,我得到了错误

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

以上是版本问题还是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!');
});

和索引html文件

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

和包装版本

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

我的节点和npm版本n是

节点为:12.16.1npm为:6.13.4

请任何人解决这个问题。。。

我也面临这个问题,经过大量分析,我发现这是因为我的机器上安装了Antivirus。特别感谢Sophos。您可以在-https://community.sophos.com/intercept-x-endpoint/f/discussions/134136/sophos-network-threat-detection-is-blocking-cypress-automation-tool上找到此问题

要解决这个问题,请尝试在Electron浏览器上执行您的测试用例,或者联系您的管理团队,获取Sophos的密码,然后获取Login into the Sophos, Go to settings and disable 'Network Threat Protection

这个问题可能与NodeJS中的这个bug有关。您可以尝试将res.end();放在res.sendFile(...)res.send(...)调用之后。如果这不起作用,您可能需要实现一个函数来调用流程uncaughtException,或者等待Node社区如何解决这个问题。

我在使用节点16.7.0时遇到了类似的问题:

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

在检查"错误"事件后,我通过添加req.end()解决了这个问题。

我在Angular项目中尝试使用节点版本16.13.2运行"npm install"时遇到了同样的问题。

当我将节点版本切换到12.18.1时,我能够毫无问题地运行该命令。

难道你没有一个疯狂的docker实例在循环中崩溃并重新启动吗?有时它会导致随机连接重置。

最新更新