question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ECONNRESET errors when idling

See original GitHub issue

I’m trying to figure out the source of the error below, or how to catch it properly and mitigate it. I am using LDAPJS as part of an identity management pipeline to move user accounts from our ERP into Active Directory (connected over TLS with a self-signed cert). There is often idle periods in the database where no events are being dispatched, and in turn LDAPJS raises these exceptions when I assume it has nothing to do.

12:20:54 bsis-0 Error: read ECONNRESET
    at exports._errnoException (util.js:812:11)
    at TLSWrap.onread (net.js:542:26)
2015-11-03 12:20:54: App name:bsis id:0 exited with code 1
12:20:54 PM2 App name:bsis id:0 exited with code 1
2015-11-03 12:21:54: Starting execution sequence in -fork mode- for app name:bsis id:0
12:21:54 PM2 Starting execution sequence in -fork mode- for app name:bsis id:0
2015-11-03 12:21:54: App name:bsis id:0 online
12:21:54 PM2 App name:bsis id:0 online
12:21:54 bsis-0 WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
12:21:54 bsis-0 WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
12:37:54 bsis-0 Error: read ECONNRESET
    at exports._errnoException (util.js:812:11)
    at TLSWrap.onread (net.js:542:26)
2015-11-03 12:37:54: App name:bsis id:0 exited with code 1
12:37:54 PM2 App name:bsis id:0 exited with code 1
2015-11-03 12:38:54: Starting execution sequence in -fork mode- for app name:bsis id:0
12:38:54 PM2 Starting execution sequence in -fork mode- for app name:bsis id:0
2015-11-03 12:38:54: App name:bsis id:0 online
12:38:54 PM2 App name:bsis id:0 online
12:38:54 bsis-0 WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
12:38:54 bsis-0 WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
12:54:55 bsis-0 Error: read ECONNRESET
    at exports._errnoException (util.js:812:11)
    at TLSWrap.onread (net.js:542:26)
2015-11-03 12:54:55: App name:bsis id:0 exited with code 1
12:54:55 PM2 App name:bsis id:0 exited with code 1

They only show up because of my process.on('uncaughtException') handler which in turns logs the event and then auto-restarts the broker.

Ideas?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:30 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
randomsockcommented, Dec 18, 2015

👍

Thanks very much for doing the digging @tapmodo. reconnect: true does indeed auto-reconnect after this failure. This strikes me as a really important resilience feature so is a bit surprising it’s not documented. You do still need the client.on('error', ...) handler to stop the disconnection from bringing the process down first, as @pfmooney pointed out.

So an over-simplified solution looks like:

var options = {
    url: 'ldap://myad.foo.net:3268',
    reconnect: true
};
var client = ldapjs.createClient(options);
client.on('error', function(err) {
    console.warn('LDAP connection failed, but fear not, it will reconnect OK', err);
});

Job done - thanks guys!

7reactions
tapmodocommented, Nov 13, 2015

As noted above, the documentation for the Client API doesn’t mention auto-reconnecting or how to handle an eventual ECONNRESET from the server. I can’t imagine an LDAP server that never closes or resets the connection, or never goes down. Appears to be option reconnect: true?

The documentation also does not mention how to close a connection, which is necessary if you are writing a small script that should gracefully shut down after doing its work. I looked in the source and appears this can be done with client.destroy()

Both of these points would be useful to mention in the documentation. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I debug error ECONNRESET in Node.js?
A break in the connection from the client throws the error ECONNRESET in Node. I believe this is ... This means that if...
Read more >
ECONNRESET Errors - Potentially New Info & Questions - Help
I request you to kindly look for connections which are 'idle in transaction' and if you see that there are several such connections,...
Read more >
MySQL giving "read ECONNRESET" error after idle ... - YouTube
MySQL : MySQL giving "read ECONNRESET " error after idle time on node.js server [ Beautify Your Computer ...
Read more >
Addressing Networking Errors in a Microservice Based System
Resolving socket hang up and ECONNRESET errors in NodeJS ... (i.e. server closing the idle socket while the request is being sent).
Read more >
cloud storage frequently throws ECONNRESET, read or write ...
Idling a google storage connection in an external VM (at travis-ci, via a service account) isn't recreating the storage API socket errors I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found