Here's the bones of the script that worked on Windows Server 2012.
logger = system.util.getLogger("ftp_param_report")
import io
import csv
from ftplib import FTP
machine = int(machine) # '03' -> 3, etc., from viewBanner radio group.
logger.info('machine: 5 step 1')
try:
ftp.close() # This helped during debug if previous attempt didn't clean up.
except:
pass
ftp = FTP()
ftp.connect(10.11.12.13, 21)
ftp.login('ftpuser', 'mySecret') # Login.
ftp.set_pasv(False) # Required by the C-More panel for some reason.
ftp.cwd('/Built-in_Flash/Recipe') # Change Working Directory
logger.info('machine: 5 step 2')
# Read the data from the PRODUCT_SKU file.
with io.BytesIO() as binary_buffer: # io avoids having to download a file to disk with associated cleanup.
try:
# read all of products.csv into a binary buffer
logger.info('machine: 5 step 3')
ftp.retrbinary("RETR myFile.csv", binary_buffer.write) # Read the SKU file.
logger.info('machine: 5 step 4')
On upgrade to Windows Server 2019 it never gets to step 4.
Running Windows CMD FTP client on the gateway I can see there's a problem.
ftp> ls
200 Port command successful.
But then it hangs there until it times out in 900 s. The directory listing is never returned.
I think the problem is due to Windows not sticking to ports 20 and 21 (which are open for outbound) for the FTP connection and using a high port number which is blocked by Windows Firewall.
The problem can be replicated using Filezilla.
By the way, does anyone know what the 225, 217
means in the PORT command?
Has anyone got any suggestions?