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.

client leak Half-closes sockets

See original GitHub issue

in client with node v10.19.0, each time client.unbind() is called or on errors, the socket isn’t destroyed only socket.end() is called and leak an Half-closes socket.

# lsof | grep "can't identify protocol"
node      25454     root   23u     sock                0,6        0t0  773832799 can't identify protocol
node      25454     root   24u     sock                0,6        0t0  773840655 can't identify protocol
node      25456     root   23u     sock                0,6        0t0  773831258 can't identify protocol
node      25456     root   24u     sock                0,6        0t0  773831259 can't identify protocol
node      25456     root   25u     sock                0,6        0t0  773831938 can't identify protocol
node      25456     root   26u     sock                0,6        0t0  773831939 can't identify protocol
node      25456     root   27u     sock                0,6        0t0  773832361 can't identify protocol
node      25456     root   28u     sock                0,6        0t0  773832362 can't identify protocol
node      25456     root   29u     sock                0,6        0t0  773832913 can't identify protocol
node      25456     root   30u     sock                0,6        0t0  773832914 can't identify protocol
node      25456     root   31u     sock                0,6        0t0  773834034 can't identify protocol

after some time, node can’t open any file and return error EMFILE: too many open files, open

replace socket.end() by socket.destroy() in lines: https://github.com/ldapjs/node-ldapjs/blob/master/lib/client/client.js#L1096 https://github.com/ldapjs/node-ldapjs/blob/master/lib/client/client.js#L1163 https://github.com/ldapjs/node-ldapjs/blob/master/lib/client/client.js#L1177 https://github.com/ldapjs/node-ldapjs/blob/master/lib/client/client.js#L1454 solved the problem

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Rich-Taylor-osscommented, May 11, 2020

We’re also seeing this behavior. ldapjs-1.0.2 On node 12.13.1

Note I cannot reproduce this on my local MacOS environment. We only see it in our dockerized production environments.

We are connecting via secure (ldaps) to an Active Directory server.

0reactions
jsumnerscommented, Apr 22, 2020

Very likely. It would take some research into how the socket is being leaked so that it can be reaped correctly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Both sides of a TCP connection are closed when the client or ...
The client or the remote application server half-closes the TCP connection ... When traffic is passed through a user-mode data flow, both sockets...
Read more >
4.7. The Mysteries of Connection Close - HTTP - O'Reilly
Full and half closes. An application can close either or both of the TCP input and output channels. A close( ) sockets call...
Read more >
c++ - Sockets in Linux - how do I know the client has finished ...
I basically open a socket, listen, wait for a connection and open a new socket from which I read the data sent by...
Read more >
Net | Node.js v19.3.0 Documentation
createServer() ) and clients ( net.createConnection() ). ... Server , so the user can use it to interact with the client. ... Half-closes...
Read more >
TCP and UDP Socket API - W3C
This API provides interfaces to raw UDP sockets, TCP Client sockets and TCP Server ... halfClose(); // Log result of TCP connection attempt....
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