I use this function to send a file via FTPS with a PowerShell script. It is a Filezilla Server. It works fine, the file is written on the server, but the connection is not closed properly.
I get the following error :
Exception when calling "Close" with "0" argument(s): "The remote server returned an error:
(425) Unable to open data connection."
At character C:\...\transfer.ps1:57: 3
+ $ftpStream.Close();
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
Exception when calling "GetResponse" with "0" argument(s): "The remote server returned an error
: (425) Cannot open data connection."
At character C:\...\transfer.ps1:58 : 3
+ $resp = $req.GetResponse();
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
Impossible to call a method in a Null expression.
At character C:\...\transfer.ps1:60 : 3
+ $resp.Close();
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation : (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
And on the server side :
2022-02-08T11:32:42.864Z II [FTP Session 11 147.128.66.87] Session 0x1ab850b0090 with ID 11 created.
2022-02-08T11:32:42.864Z >> [FTP Session 11 147.128.66.87] AUTH TLS
2022-02-08T11:32:42.880Z << [FTP Session 11 147.128.66.87] 234 Using authentication type TLS.
2022-02-08T11:32:42.880Z II [FTP Session 11 147.128.66.87] TLS Handshake successful
2022-02-08T11:32:42.880Z II [FTP Session 11 147.128.66.87] Protocol: TLS1.2, Key exchange: ECDHE-X25519-ECDSA-SHA256, Cipher: AES-256-GCM, MAC: AEAD
2022-02-08T11:32:42.880Z >> [FTP Session 11 147.128.66.87] USER uploaduser
2022-02-08T11:32:42.880Z << [FTP Session 11 147.128.66.87] 331 Please, specify the password.
2022-02-08T11:32:42.880Z >> [FTP Session 11 147.128.66.87] PASS ****
2022-02-08T11:32:42.942Z << [FTP Session 11 147.128.66.87 uploaduser] 230 Login successful.
2022-02-08T11:32:42.942Z >> [FTP Session 11 147.128.66.87 uploaduser] PBSZ 0
2022-02-08T11:32:42.942Z << [FTP Session 11 147.128.66.87 uploaduser] 200 PBSZ=0
2022-02-08T11:32:42.942Z >> [FTP Session 11 147.128.66.87 uploaduser] PROT P
2022-02-08T11:32:42.942Z << [FTP Session 11 147.128.66.87 uploaduser] 200 Protection level set to P
2022-02-08T11:32:42.942Z >> [FTP Session 11 147.128.66.87 uploaduser] OPTS utf8 on
2022-02-08T11:32:42.942Z << [FTP Session 11 147.128.66.87 uploaduser] 202 UTF8 mode is always enabled. No need to send this command
2022-02-08T11:32:42.942Z >> [FTP Session 11 147.128.66.87 uploaduser] PWD
2022-02-08T11:32:42.942Z << [FTP Session 11 147.128.66.87 uploaduser] 257 "/" is current directory.
2022-02-08T11:32:42.942Z >> [FTP Session 11 147.128.66.87 uploaduser] TYPE I
2022-02-08T11:32:42.942Z << [FTP Session 11 147.128.66.87 uploaduser] 200 Type set to I
2022-02-08T11:32:42.942Z >> [FTP Session 11 147.128.66.87 uploaduser] PASV
2022-02-08T11:32:42.942Z << [FTP Session 11 147.128.66.87 uploaduser] 227 Entering Passive Mode (147,128,66,56,222,117)
2022-02-08T11:32:43.021Z >> [FTP Session 11 147.128.66.87 uploaduser] STOR test.txt
2022-02-08T11:32:43.021Z << [FTP Session 11 147.128.66.87 uploaduser] 150 Starting data transfer.
2022-02-08T11:32:43.036Z II [FTP Session 11 147.128.66.87 uploaduser] TLS Handshake successful
2022-02-08T11:32:43.036Z II [FTP Session 11 147.128.66.87 uploaduser] TLS Session resumed
2022-02-08T11:32:43.036Z II [FTP Session 11 147.128.66.87 uploaduser] Protocol: TLS1.2, Key exchange: ECDHE-X25519, Cipher: AES-256-GCM, MAC: AEAD
2022-02-08T11:32:43.036Z !! [FTP Session 11 147.128.66.87 uploaduser] GnuTLS error -110 in gnutls_record_recv: The TLS connection was non-properly terminated.
2022-02-08T11:32:43.036Z == [FTP Session 11 147.128.66.87 uploaduser] Client did not properly shut down TLS connection
2022-02-08T11:32:43.036Z << [FTP Session 11 147.128.66.87 uploaduser] 425 Error while transfering data: ECONNABORTED - Connection aborted
2022-02-08T11:32:43.036Z !! [FTP Session 11 147.128.66.87 uploaduser] GnuTLS error -110 in gnutls_record_recv: The TLS connection was non-properly terminated.
2022-02-08T11:32:43.036Z == [FTP Session 11 147.128.66.87 uploaduser] Client did not properly shut down TLS connection
2022-02-08T11:32:43.036Z !! [FTP Session 11 147.128.66.87 uploaduser] Control channel closed with error from source 0. Reason: ECONNABORTED - Connection aborted.
2022-02-08T11:32:43.036Z !! [FTP Server] Session 11 ended with error from source 0. Reason: ECONNABORTED - Connection aborted.
2022-02-08T11:32:43.036Z II [FTP Session 11 147.128.66.87] Session 0x1ab850b0090 with ID 11 destroyed.
Tried different things on the server firewall, even disabled it, does not change anything.
Changed "keep alive" to $False, tried to disable passive mode on both server side and changing in the script to $False, without success.
Am I missing something ?