[SFTP] Closing SFTP connections

Forge Component
(15)
Published on 21 Jul (3 weeks ago) by David Epps
15 votes
Published on 21 Jul (3 weeks ago) by David Epps

Hi,

Are all the connections made to the SFTP-server closed by the component? 

Eg.: If I do a List action, will it then open a connection, do a list and then close the connection again? Or is the SFTP-server responsible to clean all open connections after an amount of time? 


I'm asking because we are seeing a lot of open connections on our SFTP-server... 


Thank you in advance.


Wietse 

We are noticing something similar.  In our case if there is an exception on the extension side, such as File Not Found, the line to disconnect does not get called.  We are going to modify the extension to use a try/finally block and call disconnect inside the finally.

Where using the SFTP extension to send files to a share. Because this is done by BPM for each process a sftp connection is created. Only there is no way to close the connection now so a lot of connections are created. Because of security the share is not allowing more then 6 connections. Would be great if a option to close connections is added to this extension!!



Hi All,

Looking at the code, it seems that every Action includes a Connect & Disconnect. That suggests that there shouldn't be any ghost sessions hanging around.

Thanks,

Dave

David Epps wrote:

Hi All,

Looking at the code, it seems that every Action includes a Connect & Disconnect. That suggests that there shouldn't be any ghost sessions hanging around.

Thanks,

Dave

 Hi David,

But as I mentioned before, if an exception occurs at any point the disconnect line does not get called because the exception will skip that line of code.  The client is in a using block, but unfortunately its dispose method does not call disconnect either.  The only way to ensure a disconnect 100% of the time is to use a try/catch/finally block.


Greg

 

Hi Greg,

Yes, you're right...that is indeed a way for it to bypass the disconnect.

I have just made a version where all of the Actions include a try/finally block around the code between connect/disconnect. Testing it now.

David

Hi All,

Tested OK. New version on Forge.

Thanks,

David