This forum uses cookies. Click X button to hide this message. What is stored? 
Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SFTP plugin - issues with keep alive and disconnect/timeout

 
Post new topic   Reply to topic    Total Commander Forum Index -> Plugins and addons: devel.+support (English) Printable version
View previous topic :: View next topic  
Author Message
mastabog
Junior Member
Junior Member


Joined: 07 Mar 2004
Posts: 72

PostPosted: Sat Nov 17, 2012 7:45 pm    Post subject: SFTP plugin - issues with keep alive and disconnect/timeout Reply with quote

Hi,

I'm an avid user of the SFTP plugin and I should have written this post a lot sooner. I see there are no options for client initiated keep-alive messages.

It also appears that the client does not respond to server initiated keep-alive messages.

This means that some servers timeout the connection, some quite quickly ... it's quite frustrating, especially when I'm editing a remote file and the connection dies before I get a chance to save it.

Is there anything I can do to fix this on the client side? Any hidden options? The openssh libraries do support client keep-alive messages but none are exposed in the TC plugin GUI.

Anyone else ran into this problem?

Thanks.


Last edited by mastabog on Sat Nov 17, 2012 9:08 pm; edited 2 times in total
Back to top
View user's profile Send private message
mastabog
Junior Member
Junior Member


Joined: 07 Mar 2004
Posts: 72

PostPosted: Sat Nov 17, 2012 8:52 pm    Post subject: Reply with quote

I forgot to mention that both the openssh linux client (sftp) and the putty psftp client properly respond to server keep-alives and do not experience this problem.

Here are some details. The server is sshd under Linux.

1. If I enable ssh keep-alives from the server by setting ClientAliveInterval 10 and ClientAliveCountMax 3 in sshd_config then the TC client does not respond to them and the connection is severed by the server in about 40 seconds, as it perceived the client to be dead:

Code:
Nov 18 01:54:50 svr-perf sshd[4668]: subsystem request for sftp by user root
Nov 18 01:55:31 svr-perf sshd[4668]: Timeout, client not responding.


2. If sshd_config is configured with TCPKeepAlive=yes but with ClientAliveInterval=0 (i.e. only TCP level keep-alive packats from the server) then the connection dies after about 15 minutes because oddly the TC client is closing it:

Code:
Nov 18 02:00:41 svr-perf sshd[4967]: subsystem request for sftp by user root
Nov 18 02:15:45 svr-perf sshd[4967]: Read error from remote host 172.26.233.118: Connection reset by peer


3. If I disable all keep-alives from the server, nothing is different from scenario 2. ... the TC client is terminating the connection after 15 minutes:

Code:
Nov 18 02:28:07 svr-perf sshd[6032]: subsystem request for sftp by user root
Nov 18 02:43:11 svr-perf sshd[6032]: Read error from remote host 172.26.233.118: Connection reset by peer


Clearly, all server keep-alive messages are ignored by TC, both tcp and ssh level ones.

Any clues on how to make the TC sftp client either respond to server keep-alive messages, or send client keep-alive messages?

If it cannot be done now, then I'm asking Christian to implement a client keep-alive feature for this plugin ... you can just request a path, e.g. RequestAbsolutePath('.')

Regards
Back to top
View user's profile Send private message
mastabog
Junior Member
Junior Member


Joined: 07 Mar 2004
Posts: 72

PostPosted: Sat Nov 17, 2012 9:11 pm    Post subject: Reply with quote

As a side issue: using the dlls from libcurl v7.27 or v7.28 causes a fatal exception upon connection (I'm suing the 32-bit version of TC and public key auth).

Dlls from libcurl v7.26 work (it's not available on the curl page that the TC docs link to, you have to dig for it manually).

Error for v7.27 and v7.28:

Code:
---------------------------
Total Commander 8.01
---------------------------
Exception in sftpplug.wfx:FsFindFirstW!
Access violation at address 6305E326. Read of address 00000000
Windows 7 SP1 6.1 (Build 7601)

Please report this error to the Author, with a description
of what you were doing when this error occurred!

Windows exception: C0000005
Stack trace:
6305E326
444AD1  4460A5  446A22  423F38  429556  42968C
652B87  652F1A  6D682B  4AB749  4E5EA8  656449
6D6E13  4460A5  446A22  423F38  445FE3  653052
>656270  4DC7BB  638BD5  444C24  444AD1  4460A5
444A0F  446DD6  444AD1  446A22  423F38  445FE3
423F38  445F51  423F38  4460A5  446A22  423F38
445FE3  423F38  429604  42969C  6D9F34 
Raw:
4460A5  423F38  445FE3  423F38  4267A5  447AA1
444AD1  446C59  445F51  423F38  446D9B  447158
4360F3  444AD1  446CF1  435E92  446033  4460A5
446A22  446A45  423F38  429556  42968C  669CD2
40650F  6D764F  652B87  445F51  423F38  446D9B
444AD1  446CF1  4460A5  446A22  445FE3  423F38
6D5128  5DB277  5C0000  445F51  423F38  446D9B
444AD1  446CF1  4460A5  6D6E13  6CFB90  6D6781
652F1A  445FE3  423F38  696DFE  5E3EE0  5E3F04
660071  64E77E  6D682B  6547C0  4AB749  4E5EA8

Press Ctrl+C to copy this report!
Continue execution?
---------------------------
Yes   No   
---------------------------
Back to top
View user's profile Send private message
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 35077
Location: Switzerland

PostPosted: Mon Nov 19, 2012 8:26 am    Post subject: Reply with quote

Yes, it seems that the OpenSSH dll isn't compatible with the new OpenSSL 1.x included in these Libcurl versions. The error seems to occur when the OpenSSH dll tries to call the OpenSSL dll, so there is nothing I can do to fix it. Sad
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mastabog
Junior Member
Junior Member


Joined: 07 Mar 2004
Posts: 72

PostPosted: Mon Nov 19, 2012 9:28 am    Post subject: Reply with quote

ghisler(Author) wrote:
Yes, it seems that the OpenSSH dll isn't compatible with the new OpenSSL 1.x included in these Libcurl versions. The error seems to occur when the OpenSSH dll tries to call the OpenSSL dll, so there is nothing I can do to fix it. Sad

What about the actual issue of this topic? (the keep-alive and disconnection problem)
Back to top
View user's profile Send private message
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 35077
Location: Switzerland

PostPosted: Wed Nov 21, 2012 3:45 am    Post subject: Reply with quote

I'm not aware of keep alive commands on SFTP, so I wonder how this is implemeneted. Maybe they open a terminal and send bogus Unix shell commands?
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mastabog
Junior Member
Junior Member


Joined: 07 Mar 2004
Posts: 72

PostPosted: Wed Nov 21, 2012 6:55 am    Post subject: Reply with quote

ghisler(Author) wrote:
I'm not aware of keep alive commands on SFTP, so I wonder how this is implemeneted. Maybe they open a terminal and send bogus Unix shell commands?


I gave a short example in my post above:

Quote:
I'm asking Christian to implement a client keep-alive feature for this plugin ... you can just request a path, e.g. RequestAbsolutePath('.')


Basically, sending any dummy ssh/sftp commands over the secure channel will keep it alive. I guess you can implement a timer to monitor activity and when it expires, send an SFTP command that is very light in terms of traffic, like RequestAbsolutePath(.). That would keep it alive.

other sftp clients do have keep-alive features, e.g. WinSCP, see its "Connection" panel in the configuration. It can send null ssh packets or execute dummy protocol commands.
Back to top
View user's profile Send private message
Sob
Power Member
Power Member


Joined: 19 Jan 2005
Posts: 903

PostPosted: Wed Nov 21, 2012 3:25 pm    Post subject: Reply with quote

No need to handle sending dummy commands yourself, library has function for it:

http://trac.libssh2.org/wiki/KeepAlive

It's there since version 1.2.5.
Back to top
View user's profile Send private message Send e-mail
mastabog
Junior Member
Junior Member


Joined: 07 Mar 2004
Posts: 72

PostPosted: Thu Nov 22, 2012 6:56 am    Post subject: Reply with quote

That's even better. The page Sob linked to clearly says "Sending keepalive's is off by default. ". It's actually on the front page of http://trac.libssh2.org/ as well.

Christian: could you please implement it for your plugin? The inability to keep the session alive is driving me crazy ...

Would it be possible to recompile a libssh2.dll with that setting enabled by default?
Back to top
View user's profile Send private message
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 35077
Location: Switzerland

PostPosted: Thu Nov 22, 2012 8:23 am    Post subject: Reply with quote

I will consider it as an option.
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tungwaiyip
Junior Member
Junior Member


Joined: 07 Mar 2003
Posts: 21
Location: San Francisco, US

PostPosted: Fri Feb 05, 2016 12:46 pm    Post subject: Reply with quote

Any update on this? Total Commander can be very effective for sftp editing. But frequent disconnection make it a mess to recover from.
Back to top
View user's profile Send private message Visit poster's website
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 35077
Location: Switzerland

PostPosted: Mon Feb 08, 2016 4:10 am    Post subject: Reply with quote

Sorry, I haven't had the time to do this yet. It's not something you can just turn on, it has to be called regularly. And the interval isn't known - some servers may drop the connection after 15 minutes, some after 30 seconds...
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tungwaiyip
Junior Member
Junior Member


Joined: 07 Mar 2003
Posts: 21
Location: San Francisco, US

PostPosted: Mon Feb 08, 2016 12:29 pm    Post subject: Reply with quote

Many software, like PuTTY, has a configurable keepalive interval. It will be a huge improvement compares to disconnection and lost edit.
Back to top
View user's profile Send private message Visit poster's website
Bozzy
Junior Member
Junior Member


Joined: 10 Sep 2013
Posts: 6

PostPosted: Tue Mar 06, 2018 7:54 am    Post subject: Reply with quote

Still no news on that? I've had the same problem for years and I've lived with it so far, but a solution would be much appreciated.

If the library supports sending keep alives by itself, it shouldn't be too difficult to implement in SFTP plugin. I suppose it's something to "turn on" and a "packet interval" to set, maybe nothing more.

Christian?
Back to top
View user's profile Send private message
Bozzy
Junior Member
Junior Member


Joined: 10 Sep 2013
Posts: 6

PostPosted: Tue Mar 06, 2018 9:29 am    Post subject: Reply with quote

I've taken a look at libssh2. I'm not a C/C++ coder, but what I understood is that there are two functions:

- libssh2_keepalive_config: with this one you set the keepalive packets interval and if an answer from the server is expected (which could be ignored IMHO).

- libssh2_keepalive_send: this one sends the keepalive packet (if the interval is passed) and returns the number of seconds to wait until a new call is necessary.

If I understand correctly, the library doesn't send keepalives automatically, but provides useful ways to help the user send them at the right pace. It's user responsibility to call libssh2_keepalive_send every some interval (not necessary the real configured interval - it can be much more frequent, since packets are sent only when the configured interval is passed).

So, IMHO, implementing it should be very simple for a C/C++ dev. Just call configure when connecting and have a timer call send every 1s or 5s.

I simply can't imagine where to put this in the plugin sources, but maybe some C/C++ developer can... or maybe Christian itself Wink

EDIT: the interval could then be configured per-connection, as any other parameter, and the keepalive logic could be put "fixed" in the code, since if interval is set to zero, the library itself will never send keepalive packets, even if libssh2_keepalive_send is called.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> Plugins and addons: devel.+support (English) All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Imprint/Impressum: This site is maintained by Ghisler Software GmbH
Privacy Policy | Datenschutzerklńrung

Using phpBB © 2001-2005 phpBB Group