andrewrk / node-s3-client

high level amazon s3 client for node.js
MIT License
1k stars 305 forks source link

Uncaught ECONNRESET exception #120

Open Alan01252 opened 8 years ago

Alan01252 commented 8 years ago

Hi,

We've been struggling with this today, not entirely sure why the connection was getting reset yet. I'm not entirely sure looking at the code where/how it would be best to catch this. Any help would be greatly appreciated. At the moment the error isn't caught and so it takes down the node application entirely.

Stack trace follows:

Error: write ECONNRESET
    at errnoException (net.js:905:11)
    at Object.afterWrite (net.js:721:19)
---------------------------------------------
    at Socket.Readable.on (_stream_readable.js:708:33)
    at pipe (tls.js:1469:10)
    at Object.exports.connect (tls.js:1366:19)
    at Agent.createConnection (https.js:79:14)
    at Agent.createSocket (http.js:1294:16)
    at Agent.addRequest (http.js:1270:23)
    at new ClientRequest (http.js:1417:16)
    at Object.exports.request (https.js:123:10)
    at [object Object].handleRequest (/srv/opt/agricameraengine/node_modules/s3/node_modules/aws-sdk/lib/http/node.js:42:23)

Thank you!

Alan

faceleg commented 8 years ago

Are you behind a proxy? Does setting sslEnabled: false e.g. https://github.com/faceleg/node-s3-client/blob/97a90cdaaf73c359ce4efb969a0f5b1166ddffd8/test/test.js#L40 help?

Alan01252 commented 8 years ago

Thank you for your reply! :)

We're not behind a proxy, code is running on a linode and directly talking to S3. I haven't tried running without SSL and I'm not sure that's a viable option for us.

It's a really intermittent problem, we're using the library a fair bit, and it's only occasionally crashing due to this. Perhaps once every few hours.

I suspect bumping the aws-sdk library might help.

Alan01252 commented 8 years ago

Tried using your fork with updated aws-sdk that still didn't help! Will have to dedicate to look through this next week :)

Alan01252 commented 8 years ago

For anyone else who comes across this, we seem to of solved this problem by increasing the allowed connection pool further.

http.globalAgent.maxSockets = https.globalAgent.maxSockets = 100;

Seems to be working for us now.

faceleg commented 8 years ago

If you would update the readme with this tip I would be forever in your debt!