Nodejs Error: read ECONNRESET

10,896

Earlier I have faced very similar issue as you mentioned.

I debugged to find the root cause of issue by commenting the code(request to 3rd party) and finally I got the issue, which is raised because of dynamoDB. Some uncaught exception was throwing(aws-sdk) and it's not handled.

I tried by catching the exception. But it's not a good practice to caught the uncaught exception.

process.on('uncaughtException', function (err) {
    logger.log('error','UNCAUGHT EXCEPTION - keeping process alive:',  err);
});

Then I tried by changing aws configuration to fix the issue

AWS.config.httpOptions['agent'] = new https.Agent({
    keepAlive: true,
    ciphers: 'ALL',
    secureProtocol: 'TLSv1_method'
});

keepAlive: true -- I make it false, after that I did not get the issue. But it's not a right approach to do. For each request to dynamodb it will again do the handshaking, which will make little slower.

secureProtocol :'TLSv1_method' -- Also I tried with different method(https://www.openssl.org/docs/man1.0.2/ssl/TLSv1_method.html). But It did not help me

My nodejs version was 5.2. I just upgraded nodejs version to 6.11(LTS) and updated the aws-sdk package.

Now my problem solved and not getting a single issue.

Share:
10,896
rahulb
Author by

rahulb

Updated on June 13, 2022

Comments

  • rahulb
    rahulb almost 2 years

    I am using Nodejs in one of my app for web socket communication.

    This app sends user data to AWS dynamodb periodically. I am getting lots of new relic alterts with below stacktace:

    Error: read ECONNRESET
     at exports._errnoException (util.js:856:11)
     at TLSWrap.onread (net.js:545:26) /
    

    I just want to understand why this TLSWrap error occurs.

    Thanks in advance

  • rahulb
    rahulb almost 7 years
    Thanks! After upgradeing my node server, i can't see the error.