Bug 47414

Summary: [PATCH] Add Ftp ant task timeout
Product: Ant Reporter: Chuchi <chuchiperriman>
Component: Optional TasksAssignee: Ant Notifications List <notifications>
Status: RESOLVED FIXED    
Severity: enhancement CC: eugene.adell
Priority: P3 Keywords: PatchAvailable
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: patch introducing a reading timeout for FTP

Description Chuchi 2009-06-24 02:22:55 UTC
I have a lot of problems with the FTP timeout because we run a lot of ant tasks using the ftp and, if one stops by a infinite timeout, all the next task will never run.

FtpClient supports the timeout, IMO only adding a timeout property to FTP task is ok because in the code is very easy fix this problem.
Comment 1 Leo Sauermann 2011-06-21 15:26:41 UTC
I am working with Ant FTP to transfer (GET) files from a website. To minimize traffic, the depends="yes" and retriesAllowed="5" is set. Still, the ant ftp task hangs on some files and the task does not continue. The script hangs (for hours, days). 

Assuming that this problem is related to timeouts, I also would love to see this feature implemented. 

There are reported implementations (as a "hack"):
http://evgeny-goldin.com/blog/ant-ftp-task-progress-indicator-timeout/
Comment 2 Eugène Adell 2019-03-01 22:14:52 UTC
Created attachment 36473 [details]
patch introducing a reading timeout for FTP

the attachment is in text format

Short Description
Introduce a read timeout, then receiving files which look infinite will not hang anymore. Sending is not concerned, as timeout will already occur if necessary.

Tests
It should be tested seriously, as FTP is not the most simple thing, and because we rely on external library (commons-net).
My tests are OK for now, but maybe do you have servers to test against.

What the patch does :
 . Introduce the dataTimeout as suggested by a comment, which will make impossible any infinite reading (described as 'FTP hangs' by many)
 . Call the abort command when the timeout is detected, then the server will be notified it should stop sending the current file. This abort is not sent in any urgent mode as described by RFC 959, as the commons-net doesn't support this feature yet. Although the effects are unsure since all servers are not implemented the same way, this feature is here to be compliant with the RFC.
Comment 3 J.M. (Martijn) Kruithof 2019-07-12 14:10:58 UTC
Patch as provided manually verified and applied. I also updated the docs