This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ftplib timeouts for misconfigured server
Type: enhancement Stage: resolved
Components: Versions: Python 3.9
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: davispuh, giampaolo.rodola
Priority: normal Keywords: patch

Created on 2019-04-09 07:57 by davispuh, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 12740 open davispuh, 2019-04-09 08:05
Messages (3)
msg339712 - (view) Author: Dāvis (davispuh) * Date: 2019-04-09 07:57
It's not uncommon to encounter FTP servers which are misconfigured and return unroutable host IP (eg. internal IP) when using passive mode

See: https://superuser.com/a/1195591

Most FTP clients such as FileZilla and WinSCP use a workaround when they encounter such servers and connect to user's specified host instead.

> Command: PASV
> Answer: 227 Entering Passive Mode (10,250,250,25,219,237).
> Status:  Server sent passive reply with unroutable address. Using server address instead.

Currently Python's ftplib simply timeouts for these and doesn't work.
msg339715 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2019-04-09 08:43
Please no. The mistake should be fixed in the misconfigured FTP server, not in ftplib, which should not make this event pass unnoticed or take arbitrary decisions. Filezilla is different than ftplib in that it's an end-user app. ftplib is not (e.g. it can be used for testing FTP server implementations, like pyftpdlib).

A possible alternative is making socket.create_connection() show the address in case of error, like we do in socket.create_server:
https://github.com/python/cpython/blob/8702b67dad62a9084f6c1823dce10653743667c8/Lib/socket.py#L803-L805
That would at least provide a hint on what's the real issue. If you want to provide a patch for that you have my blessing.
msg339725 - (view) Author: Dāvis (davispuh) * Date: 2019-04-09 10:37
The problem is that most of time you have no control over that FTP server but you still want to download files from that FTP server using Python. Currently that's just not possible. Maybe there could be some flag to enable workarounds for these cases.
History
Date User Action Args
2022-04-11 14:59:13adminsetgithub: 80751
2019-04-09 10:37:31davispuhsetmessages: + msg339725
2019-04-09 08:43:18giampaolo.rodolasetstatus: open -> closed
resolution: rejected
messages: + msg339715

stage: patch review -> resolved
2019-04-09 08:05:18davispuhsetkeywords: + patch
stage: patch review
pull_requests: + pull_request12662
2019-04-09 07:57:09davispuhcreate