Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exhaust NOOP responses also after 226 Transfer complete #507

Merged

Conversation

aliquid
Copy link

@aliquid aliquid commented Jan 6, 2020

... or respond at the end of the file transfer (have no such evidence, but pull request attempted to cope with that in a rudimentary manner).

Writing above got me thinking, adding below to just before the break in Upload/DownloadFileInternal/Async would make coping with NOOP responses less rudimentary and more robust by exhausting them not only before the "226 Transfer complete." but also after it (as should be the case, as specified by "4.2 FTP REPLIES" in the RFC 959). Of course Execute() can do that (if StaleDataCheck = true) with its ReadStaleData(true, ..), but with the side-effect of dropping the connection and opening a new.

This is theory as I have no evidence for it. I cannot experiment with all our endpoints to see if any would be responding at all to NOOPs during file transfers, only with our internal which runs IIS. Perhaps others reading could help provide evidence one way or the other by uploading/downloading two files consequtively with NoopInterval configured to see if it triggers with StaleDataCheck = true? I tested multiple consecutive uploads and downloads but with IIS there are no NOOP responses during file transfer so existing code stands file.

No problem. Below from my testing but again it shows no evidence the added code does anything.

Uploading, with IIS no sign of stale data after 226 Transfer complete.;

Connecting...
# Connect()
Status:   Connecting to ***:21
Response: 220 Microsoft FTP Service
Status:   Detected FTP server: WindowsServerIIS
Command:  USER ***
Response: 331 Password required for ***.
Command:  PASS ***
Response: 230 User *** logged in.
Command:  FEAT
Response: 211-FEAT
Response: SIZE
Response: MDTM
Response: 211 END
Status:   Text encoding: System.Text.ASCIIEncoding
Command:  SYST
Response: 215 Windows_NT
Changing directory...
# SetWorkingDirectory("/***/temp")
Command:  CWD /***/temp
Response: 250 CWD command successful.
Uploading...
# Upload("IgnoreMe1.tmp", Overwrite, False)

# FileExists("IgnoreMe1.tmp")

# GetWorkingDirectory()
Command:  PWD
Response: 257 "/***/temp" is current directory.
Command:  SIZE /***/temp/IgnoreMe1.tmp
Response: 213 75869544

# DeleteFile("IgnoreMe1.tmp")
Command:  DELE IgnoreMe1.tmp
Response: 250 DELE command successful.

# OpenWrite("IgnoreMe1.tmp", Binary)
Command:  TYPE I
Response: 200 Type set to I.

# OpenPassiveDataStream(AutoPassive, "STOR IgnoreMe1.tmp", 0)
Command:  EPSV
Response: 500 'EPSV': command not understood

# OpenPassiveDataStream(PASV, "STOR IgnoreMe1.tmp", 0)
Command:  PASV
Response: 227 Entering Passive Mode (***).
Status:   Connecting to ***:2966
Command:  STOR IgnoreMe1.tmp
Response: 125 Data connection already open; Transfer starting.
Command:  NOOP
Command:  NOOP
Command:  NOOP
Command:  NOOP
Command:  NOOP
Command:  NOOP
Command:  NOOP
Command:  NOOP
Status:   Disposing FtpSocketStream...
Response: 226 Transfer complete.
Uploading...
# Upload("IgnoreMe1.tmp", Overwrite, False)

# FileExists("IgnoreMe1.tmp")

# GetWorkingDirectory()
Command:  PWD
Response: 257 "/***/temp" is current directory.
Command:  SIZE /***/temp/IgnoreMe1.tmp
Response: 213 75869544

# DeleteFile("IgnoreMe1.tmp")
Command:  DELE IgnoreMe1.tmp
Response: 250 DELE command successful.

# OpenWrite("IgnoreMe1.tmp", Binary)

# OpenPassiveDataStream(AutoPassive, "STOR IgnoreMe1.tmp", 0)
Command:  PASV
Response: 227 Entering Passive Mode (***).
Status:   Connecting to ***:3217
Command:  STOR IgnoreMe1.tmp
Response: 125 Data connection already open; Transfer starting.
Command:  NOOP
Command:  NOOP
Command:  NOOP
Command:  NOOP
Command:  NOOP
Command:  NOOP
Command:  NOOP
Command:  NOOP
Status:   Disposing FtpSocketStream...
Response: 226 Transfer complete.
Disconnecting...Command:  QUIT
Response: 221
Status:   Disposing FtpSocketStream...

# Dispose()
Status:   Disposing FtpClient object...
Status:   Disposing FtpSocketStream...
Done in 86241 milliseconds

Downloading, with IIS no sign of stale data after 226 Transfer complete.;

Connecting...
# Connect()
Status:   Connecting to ***:21
Response: 220 Microsoft FTP Service
Status:   Detected FTP server: WindowsServerIIS
Command:  USER ***
Response: 331 Password required for ***.
Command:  PASS ***
Response: 230 User *** logged in.
Command:  FEAT
Response: 211-FEAT
Response: SIZE
Response: MDTM
Response: 211 END
Status:   Text encoding: System.Text.ASCIIEncoding
Command:  SYST
Response: 215 Windows_NT
Downloading...
# Download("/***/temp/IgnoreMe1.tmp")

# OpenRead("/***/temp/IgnoreMe1.tmp", Binary, 0)
Command:  TYPE I
Response: 200 Type set to I.

# OpenPassiveDataStream(AutoPassive, "RETR /***/temp/IgnoreMe1.tmp", 0)
Command:  EPSV
Response: 500 'EPSV': command not understood

# OpenPassiveDataStream(PASV, "RETR /***/temp/IgnoreMe1.tmp", 0)
Command:  PASV
Response: 227 Entering Passive Mode (***).
Status:   Connecting to ***:3423
Command:  RETR /***/temp/IgnoreMe1.tmp
Response: 125 Data connection already open; Transfer starting.
Command:  NOOP
Command:  NOOP
Command:  NOOP
Command:  NOOP
Status:   Disposing FtpSocketStream...
Response: 226 Transfer complete.
Downloading...
# Download("/***/temp/IgnoreMe1.tmp")

# OpenRead("/***/temp/IgnoreMe1.tmp", Binary, 0)

# OpenPassiveDataStream(AutoPassive, "RETR /***/temp/IgnoreMe1.tmp", 0)
Command:  PASV
Response: 227 Entering Passive Mode (***).
Status:   Connecting to ***:3504
Command:  RETR /***/temp/IgnoreMe1.tmp
Response: 125 Data connection already open; Transfer starting.
Command:  NOOP
Command:  NOOP
Command:  NOOP
Command:  NOOP
Status:   Disposing FtpSocketStream...
Response: 226 Transfer complete.
Disconnecting...Command:  QUIT
Response: 221
Status:   Disposing FtpSocketStream...

# Dispose()
Status:   Disposing FtpClient object...
Status:   Disposing FtpSocketStream...
Done in 42913 milliseconds

@robinrodricks
Copy link
Owner

Awesome! One small question, what if there are no responses? Will it block forever at the ReadStaleData call?

@robinrodricks
Copy link
Owner

Sorry! Just read your comment and you've tested this, which is great. Thanks again.

@robinrodricks robinrodricks merged commit ca189ac into robinrodricks:master Jan 6, 2020
@aliquid
Copy link
Author

aliquid commented Jan 6, 2020

Yeah no ReadStaleData/Async is effectively a no-op if there is no available data. It does not even poll.

Only reason for available data would be superfluous responses, and new code only bothers if it knows it sent any NOOPs.

@aliquid aliquid deleted the features/387-NoopInterval-take2 branch January 6, 2020 13:39
@robinrodricks robinrodricks changed the title #387 exhaust NOOP responses also after 226 Transfer complete Exhaust NOOP responses also after 226 Transfer complete Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants