Jacques44 / node-red-contrib-bigssh

remote command using ssh big node
Apache License 2.0
8 stars 12 forks source link

node not closing/reusing SSH connections #3

Closed jonferreira closed 6 years ago

jonferreira commented 7 years ago

Hi,

I've recently noticed that bigssh node doesn't close or re-use SSH connections. What this means is every time a node is triggered it will create a new SSH session and eventually overtime you end up with hundreds of connections making my RPI3 finally crash and reject any more sessions.

Is it possible to simply close or re-use and existing SSH session?

Traste commented 7 years ago

I have seen the same behavior, though in my case the router i am connecting to is crashing before the Rpi. I tried adding ;exit at the end of the command it is executing, but that doesn't seem to make any difference. 29 days without any response, is this still supported?

88weighed commented 7 years ago

This is a serious bug. This node is breaking machines. I'm getting "out of memory" errors because of the number of SSH sessions open.

As far as I can see, the node should be using end() to disconnect te session, I can only see that it's using close() which is used for errors. https://www.npmjs.com/package/ssh2#client

Jacques44 commented 7 years ago

Hello, I'm not working any more on this project because of lack of time. But as you seem in trouble, I can have a look ... :-) Please can you tell me how you are using this node? The "big" series is designed to work by combining multiple messages. Can you make me a sample test case?

88weighed commented 6 years ago

I have already worked around this by using sockets and communicating directly. The issue for this should still be fixed though. The bigssh issue leaves every session open, creating a memory leak. It should either reuse the session, or (preferably) close it.

As you can see below, sessions from July 6th, created by the bigssh node are still open three weeks later:

pi@fancontrol ~ $ ps aux | grep ssh
root      4224  0.0  2.4   9324  4500 ?        Ss   Jul23   0:00 sshd: pi [priv]
pi        4227  0.0  1.7   9324  3164 ?        S    Jul23   0:00 sshd: pi@notty
root      5473  1.0  2.4   9364  4444 ?        Ss   14:09   0:00 sshd: pi [priv]
pi        5476  0.3  1.7   9364  3216 ?        S    14:09   0:00 sshd: pi@pts/0
pi        5494  0.0  0.9   3564  1772 pts/0    S+   14:09   0:00 grep --color=auto ssh
root      6437  0.0  2.4   9364  4512 ?        Ss   Jul16   0:00 sshd: pi [priv]
pi        6440  0.0  1.7   9364  3184 ?        S    Jul16   0:00 sshd: pi@notty
root      6697  0.0  2.4   9364  4552 ?        Ss   Jul16   0:00 sshd: pi [priv]
pi        6700  0.0  1.7   9364  3276 ?        S    Jul16   0:00 sshd: pi@notty
root     13970  0.0  2.4   9364  4484 ?        Ss   Jul16   0:00 sshd: pi [priv]
pi       13973  0.0  1.7   9364  3188 ?        S    Jul16   0:00 sshd: pi@notty
root     20746  0.0  1.6   6240  2968 ?        Ss   Jun26   0:00 /usr/sbin/sshd
root     29493  0.0  2.4   9364  4440 ?        Ss   Jul23   0:00 sshd: pi [priv]
pi       29496  0.0  1.7   9364  3192 ?        S    Jul23   0:00 sshd: pi@notty
pi@fancontrol ~ $ date
Wed Jul 26 14:09:33 CEST 2017
Jacques44 commented 6 years ago

Noticed, I'm having a look

Regards

Jacques44 commented 6 years ago

You're totally right. This has been solved

pokryva commented 6 years ago

@Jacques44 are you releasing this to npm?

Jacques44 commented 6 years ago

Should be ok, sorry :-)