FluentFTP icon indicating copy to clipboard operation
FluentFTP copied to clipboard

FluentFTP gets out of sync when server sends "150 Opening BINARY mode data connection for file list" response

Open climam opened this issue 4 years ago • 1 comments

FTP OS: Unix

FluentFTP Version: 33.0.3

I am using FluentFTP high level API to upload files on a pretty old FTP server. This FTP server sends a response code 150 after execution of some commands such as NLST. Looking at the FTP specifications, FluentFTP should fetch another reply from the FTP server before sending a command. This is not the case and as a result, FluentFTP gets out of sync (see logs below).

See https://en.wikipedia.org/wiki/List_of_FTP_server_return_codes

1xx: Positive Preliminary reply The requested action is being initiated; expect another reply before proceeding with a new command. (The user-process sending another command before the completion reply would be in violation of protocol; but server-FTP processes should queue any commands that arrive while a preceding command is in progress.) This type of reply can be used to indicate that the command was accepted and the user-process may now pay attention to the data connections, for implementations where simultaneous monitoring is difficult. The server-FTP process may send at most, one 1xx reply per command.

-- | --

Logs :


# OpenPassiveDataStreamAsync(PASV, "NLST /__TESTS__", 0)
Command:  PASV
Response: 227 Entering Passive Mode (212,27,63,3,178,6).
Status:   Connecting to 212.27.63.3:45574
Command:  NLST /__TESTS__
Response: 150 Opening BINARY mode data connection for file list
Loaded '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.2.7/System.Diagnostics.StackTrace.dll'. Module was built without symbols.
Loaded '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.2.7/System.Reflection.Metadata.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

# UploadAsync("__TESTS__/lastConnetion.txt", Append, True)

# FileExistsAsync("__TESTS__/lastConnetion.txt")

# GetWorkingDirectoryAsync()
Command:  PWD
Response: 226 Transfer complete.
Warning:  Failed to parse working directory from: Transfer complete.

# GetNameListingAsync("./__TESTS__")

# GetWorkingDirectoryAsync()
Command:  PWD
Response: 257 "/" is current directory.
Command:  TYPE I
Response: 257 "/" is current directory.

# OpenPassiveDataStreamAsync(PASV, "NLST /__TESTS__", 0)
Command:  PASV
Response: 200 Type set to I
Exception thrown: 'FluentFTP.FtpException' in System.Private.CoreLib.dll
Command:  QUIT
Response: 227 Entering Passive Mode (212,27,63,3,120,32).
Status:   Disposing FtpSocketStream...

# Dispose()
Status:   Disposing FtpClient object...
Status:   Disposing FtpSocketStream...


climam avatar Jan 18 '21 09:01 climam

We are not built to handle "preliminary replies". At present we support an error reply 5xx and the success reply 2xx. If you feel this is a good feature, you may contribute it and submit a PR we would happily accept.

robinrodricks avatar Feb 10 '21 14:02 robinrodricks

Added to the bucket list. We will pick this up as and when we have free time. Comment on this issue if you want us to prioritize it. Thanks!

robinrodricks avatar Sep 19 '22 14:09 robinrodricks

This works fine since quite some time. Removed from bucket list.

FanDjango avatar Jan 25 '23 11:01 FanDjango

Awesome!

robinrodricks avatar Jan 25 '23 14:01 robinrodricks