[Twisted-Python] Hanging SFTP client operations on server disconnection

Glyph Lefkowitz glyph at twistedmatrix.com
Tue Feb 14 23:56:29 MST 2017


> On Feb 2, 2017, at 2:43 AM, Adi Roiban <adi at roiban.ro> wrote:
> 
> Hi,
> 
> t.conch.ssh.filetransfer.FileTransferClient._sendRequest keeps a
> mapping with active SFTP requests in self.openRequests
> 
> The self.openRequests is only updated when the server is responding
> for that request.
> 
> They are not cleared/cancelled on connection lost.
> 
> In the case in which the client send a request in the exact same time
> in which the server closes the connect , the client will send the
> request as there is no way to know that the server is gone... but
> since the server is gone it will not reply to the response... and the
> deferred is never called.
> 
> To solve this issue, I went for cancelling the open requests when the
> connection is close.

That sounds correct.  Is there a ticket for this?

> I assume that this is also an issue with bad behaved servers which
> will just ignore a request... so instead of a simple deferred, there
> is the need to use a timeout deferred.
> 
> Is this a bug?
> I am wondering if I am doing something wrong and these type of errors
> should be handled in a different way.

Generally speaking, any Deferred attached to a connection object (regardless of protocol) should be failed with a connection failure error of some kind when the connection is dropped.

> Thanks!
> 
> PS: There is a stray release notes fragment in conch
> https://github.com/twisted/twisted/blob/trunk/src/twisted/conch/8791.feature <https://github.com/twisted/twisted/blob/trunk/src/twisted/conch/8791.feature>

Oops!

Wait; why do you say this is "stray"?

-glyph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20170214/74d388d7/attachment-0002.html>


More information about the Twisted-Python mailing list