in reply to Working around limit to number of connections with Net::OpenSSH

This node suggest undef too 903706

From the documentation: OpenSSH multiplexing feature requires passing file handles through sockets

So how about the number of open sockets just before it dies?

find /proc/net/* -type f -exec wc -l {} \; |sort -n

also try: ss -s and ss -a (or netstat, but I am sure you used that already)

What do you get for the following: cat /proc/sys/fs/file-max and limit ?

what about a forked process? Could you fork a child, let it work and die... and maybe that drops the hanging connection? (of course, that adds to complexity)

Replies are listed 'Best First'.
Re^2: Working around limit to number of connections vis Net::OpenSSH
by nysus (Parson) on Mar 27, 2017 at 21:14 UTC

    Woot! You guys are friggin' geniuses. Open file limit on Mac is 256. I bumped to 512 and all is well. Thanks!

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      Looking at the code excerpt you have posted, it seems unlikely that you need the 256 files opened simultaneously. Probably, your code or some of the modules you are using or the OpenSSH binary is leaking file descriptors in some way.

      Increasing the available file descriptors is just going to hide and delay the issue but not to solve it.

      Net::OpenSSH has a debug mode you can enable setting $Net::OpenSSH::debug=-1, and you can also pass the flags -vvv to the ssh client in order to find where your program is failing.

        I agree. I'm just happy to figure out why the code wasn't working. Ideally I'd like for the new file objects to re-use an existing Net::OpenSSH object or destroy existing objects that use the connection. I'm currently trying to figure out how to do that.

        $PM = "Perl Monk's";
        $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
        $nysus = $PM . ' ' . $MCF;
        Click here if you love Perl Monks