FluentFTP icon indicating copy to clipboard operation
FluentFTP copied to clipboard

Downloading error when connecting through SOCKS4 / SOCKS4a proxy

Open fire-lizard opened this issue 2 years ago • 10 comments

FTP OS: Windows

FTP Server: Reproduced on WindowsServerIIS, XLight, EFT and FileZilla

Computer OS: Windows

FluentFTP Version: 38.0.0

When I am trying to download file through SOCK4 / SOCKS4a proxy I get the error: Failed to get the EPSV port from: 442629 Please note that 442629 is the file size, when I try to download different file, I got different number here, which is also a file size. When I download through SOCKS5 or without proxy at all, everything is ok. Also it works ok with TitanFTP.

Logs :



# Connect()
Status:   Connecting to ***:1080
Response: 220 Xlight FTP Server 3.8 ready...
Status:   Detected FTP server: XLight
Command:  USER ***
Response: 331 Password required for nuser
Command:  PASS ***
Response: 230 Login OK
Command:  FEAT
Response: 211-Features supported
Response: REST STREAM
Response: EPRT
Response: EPSV
Response: SIZE
Response: MDTM
Response: MFMT
Response: AUTH
Response: PBSZ
Response: PROT
Response: MLST type*;size*;modify*;
Response: MLSD
Response: 211 End
Status:   Text encoding: System.Text.ASCIIEncoding
Command:  SYST
Response: 215 UNIX Type: L8
Status:   Listing parser set to: Machine

# GetFileSize("ValidFeed.xml")
Command:  SIZE ValidFeed.xml
Response: 213 442629

# Download("ValidFeed.xml")

# GetFileSize("ValidFeed.xml")
Command:  SIZE ValidFeed.xml
Response: 213 442629

# OpenRead("ValidFeed.xml", Binary, 0, 442629)
Command:  TYPE I
Response: 200 Type set to I.

# OpenPassiveDataStream(AutoPassive, "RETR ValidFeed.xml", 0)
Command:  EPSV
Response: 229 Entering Passive Mode (|||50312|)
Status:   Connecting to ***:1080
Command:  RETR ValidFeed.xml
Response: 150 Opening BINARY mode data connection for ValidFeed.xml (442629 bytes).
Status:   Disposing FtpSocketStream...

# OpenRead("ValidFeed.xml", Binary, 442635, 0)

# GetFileSize("ValidFeed.xml")
Command:  SIZE ValidFeed.xml
Response: 226 Transfer complete (7025.857 KB/s).

# OpenPassiveDataStream(AutoPassive, "RETR ValidFeed.xml", 442635)
Command:  EPSV
Response: 213 442629
Status:   Disposing FtpSocketStream...


fire-lizard avatar Jul 12 '22 12:07 fire-lizard

Since you contributed SOCKS4x support into the library you would be the best person to debug this.

robinrodricks avatar Jul 17 '22 11:07 robinrodricks

Looks like error is gone for Windows IIS and FileZilla after these code changes (still remains for XLight though):

https://github.com/robinrodricks/FluentFTP/pull/893

fire-lizard avatar Jul 19 '22 12:07 fire-lizard

Please check if this works for you:

https://www.nuget.org/packages/FluentFTP/37.1.2

robinrodricks avatar Jul 22 '22 06:07 robinrodricks

I have checked it and confirm that it fixed problem for WindowsIIS and FileZilla. Unfortunately there is still Failed to get the EPSV port from: [file size] problem with XLight.

fire-lizard avatar Jul 22 '22 12:07 fire-lizard

I used your same code, just kept it for proxy and not for normal FTP client since I'm not sure if it will mess something up.

robinrodricks avatar Jul 23 '22 06:07 robinrodricks

Reproduced issue (using the latest version of FluentFTP) on EFT server as well

fire-lizard avatar Jul 26 '22 14:07 fire-lizard

Did it work with your fork? (As I said, I used your code)

robinrodricks avatar Jul 31 '22 13:07 robinrodricks

Yes, it did. It fixed issue with download restarting (for Windows IIS and FileZilla), but not "Failed to get EPSV port [file size]" issue (for XLight and EFT)

fire-lizard avatar Jul 31 '22 18:07 fire-lizard

I am in process of creating a new test suite which uses dockerized FTP servers. Can you recommend any dockers for these FTP Servers which you are testing OR any of the proxies?

robinrodricks avatar Aug 01 '22 05:08 robinrodricks

I am using 3proxy (https://github.com/3proxy/3proxy) as proxy server (supports both SOCKS4 and SOCKS5). There is my config for 3proxy:

auth none
log
socks

I don't use any dockers, I am using VMware Workstation 16.2.3 with Windows 11 on it, where I installed Windows IIS FTP, FileZilla, TitanFTP, XLight and EFT.

fire-lizard avatar Aug 01 '22 09:08 fire-lizard

Looks like I fixed this bug for XLight and EFT too. Please see pull request #947

fire-lizard avatar Sep 13 '22 02:09 fire-lizard