Question about correct termination of datastream

Need help with FileZilla Server? Something does not work as expected? In this forum you may find an answer.

Moderator: Project members

Post Reply
Message
Author
MaartenPl
500 Command not understood
Posts: 4
Joined: 2021-09-03 06:47
First name: Maarten
Last name: PL

Question about correct termination of datastream

#1 Post by MaartenPl » 2021-09-03 07:04

Hello,

I am a PLC programmer and I am facing an issue.
I have started implementing an FTP-client in a Siemens PLC.
A PLC is not a computer as most people know it. It is more of a lower level device.
Coding is done with a limited instruction set.

I am uploading lots of tiny text files to the filezilla-server, which is running on a virtual machine that is running Windows Server 2019.
The uploading of the files works. The files are at the correct location, and contain the correct data.

However the file transfer is not being terminated as it should. Below is an example of the log file.
I think the transfer eventually closes by a timeout of about 4 seconds.
Because of this delay, I can't send everything in the allowed time.

I have looked around the web at ftp specifications, but honestly it is a bit beyond me because I am not a software developer of that caliber.
Can somebody explain to me what the problem is, or how the datastream should be terminated?

(000076)9/3/2021 8:56:42 AM - engadmin (192.168.0.62)> PORT 192,168,0,62,7,218
(000076)9/3/2021 8:56:42 AM - engadmin (192.168.0.62)> 200 Port command successful
(000076)9/3/2021 8:56:42 AM - engadmin (192.168.0.62)> APPE \Utilities\Electricity\ALSB1\Reactive Power L2 (var)\2021\9\3\UTC06.data
(000076)9/3/2021 8:56:42 AM - engadmin (192.168.0.62)> 150 Opening data channel for file upload to server of "/Utilities/Electricity/ALSB1/Reactive Power L2 (var)/2021/9/3/UTC06.data", restarting at offset 544
(000076)9/3/2021 8:56:47 AM - engadmin (192.168.0.62)> 426 Connection closed; aborted transfer of "/Utilities/Electricity/ALSB1/Reactive Power L2 (var)/2021/9/3/UTC06.data"
(000076)9/3/2021 8:56:47 AM - engadmin (192.168.0.62)> PORT 192,168,0,62,7,218
(000076)9/3/2021 8:56:47 AM - engadmin (192.168.0.62)> 200 Port command successful
(000076)9/3/2021 8:56:47 AM - engadmin (192.168.0.62)> APPE \Utilities\Electricity\ALSB1\Reactive Power L3 (var)\2021\9\3\UTC06.data
(000076)9/3/2021 8:56:47 AM - engadmin (192.168.0.62)> 150 Opening data channel for file upload to server of "/Utilities/Electricity/ALSB1/Reactive Power L3 (var)/2021/9/3/UTC06.data", restarting at offset 504
(000076)9/3/2021 8:56:52 AM - engadmin (192.168.0.62)> 426 Connection closed; aborted transfer of "/Utilities/Electricity/ALSB1/Reactive Power L3 (var)/2021/9/3/UTC06.data"
(000076)9/3/2021 8:56:52 AM - engadmin (192.168.0.62)> PORT 192,168,0,62,7,218
(000076)9/3/2021 8:56:52 AM - engadmin (192.168.0.62)> 200 Port command successful
(000076)9/3/2021 8:56:52 AM - engadmin (192.168.0.62)> APPE \Utilities\Electricity\ALSB1\Max Current L1 (A)\2021\9\3\UTC06.data
(000076)9/3/2021 8:56:52 AM - engadmin (192.168.0.62)> 150 Opening data channel for file upload to server of "/Utilities/Electricity/ALSB1/Max Current L1 (A)/2021/9/3/UTC06.data", restarting at offset 540
(000076)9/3/2021 8:56:57 AM - engadmin (192.168.0.62)> 426 Connection closed; aborted transfer of "/Utilities/Electricity/ALSB1/Max Current L1 (A)/2021/9/3/UTC06.data"
(000076)9/3/2021 8:56:57 AM - engadmin (192.168.0.62)> PORT 192,168,0,62,7,218
(000076)9/3/2021 8:56:57 AM - engadmin (192.168.0.62)> 200 Port command successful
(000076)9/3/2021 8:56:57 AM - engadmin (192.168.0.62)> APPE \Utilities\Electricity\ALSB1\Max Current L2 (A)\2021\9\3\UTC06.data
(000076)9/3/2021 8:56:57 AM - engadmin (192.168.0.62)> 150 Opening data channel for file upload to server of "/Utilities/Electricity/ALSB1/Max Current L2 (A)/2021/9/3/UTC06.data", restarting at offset 7839
(000076)9/3/2021 8:57:02 AM - engadmin (192.168.0.62)> 426 Connection closed; aborted transfer of "/Utilities/Electricity/ALSB1/Max Current L2 (A)/2021/9/3/UTC06.data"


Thanks,

Maarten

User avatar
botg
Site Admin
Posts: 35491
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

Re: Question about correct termination of datastream

#2 Post by botg » 2021-09-03 14:01

There's nothing special to closing the data connection. At the end of the transfer all the sender needs to do is to close the TCP connection. See https://datatracker.ietf.org/doc/html/r ... ection-3.5 how to close a TCP connection.

MaartenPl
500 Command not understood
Posts: 4
Joined: 2021-09-03 06:47
First name: Maarten
Last name: PL

Re: Question about correct termination of datastream

#3 Post by MaartenPl » 2021-09-10 06:44

Thanks for pointing me in the right direction.

Instead of trying to figure out how the Siemens block works, I have rewritten it and learned alot.
I still have the 426 response however. The good thing is that I no longer have the delay between sends, so it is less of a problem for me.
It is just less clean as I would have hoped.

So I open an active control connection and receive a passive data connection.
I immediately send a disconnect on the data connection when I get the 'job completed without error' signal on the data connection and get the 426 response on the control connection.
I keep the control connection open for the next files.

(001905)9/10/2021 8:34:02 AM - engadmin (192.168.0.62)> 200 Port command successful
(001905)9/10/2021 8:34:02 AM - engadmin (192.168.0.62)> APPE \Utilities\Electricity\HVFS_IR-oven\Current L3 (A)\2021\9\10\UTC06.data
(001905)9/10/2021 8:34:02 AM - engadmin (192.168.0.62)> 150 Opening data channel for file upload to server of "/Utilities/Electricity/HVFS_IR-oven/Current L3 (A)/2021/9/10/UTC06.data", restarting at offset 261
(001905)9/10/2021 8:34:02 AM - engadmin (192.168.0.62)> 426 Connection closed; aborted transfer of "/Utilities/Electricity/HVFS_IR-oven/Current L3 (A)/2021/9/10/UTC06.data"
(001905)9/10/2021 8:34:02 AM - engadmin (192.168.0.62)> PORT 192,168,0,62,7,218
(001905)9/10/2021 8:34:02 AM - engadmin (192.168.0.62)> 200 Port command successful
(001905)9/10/2021 8:34:02 AM - engadmin (192.168.0.62)> APPE \Utilities\Electricity\HV RSB-line Monttech\total_Wh\2021\9\10\UTC06.data
(001905)9/10/2021 8:34:02 AM - engadmin (192.168.0.62)> 150 Opening data channel for file upload to server of "/Utilities/Electricity/HV RSB-line Monttech/total_Wh/2021/9/10/UTC06.data", restarting at offset 174
(001905)9/10/2021 8:34:03 AM - engadmin (192.168.0.62)> 426 Connection closed; aborted transfer of "/Utilities/Electricity/HV RSB-line Monttech/total_Wh/2021/9/10/UTC06.data"
(001905)9/10/2021 8:34:03 AM - engadmin (192.168.0.62)> PORT 192,168,0,62,7,218
(001905)9/10/2021 8:34:03 AM - engadmin (192.168.0.62)> 200 Port command successful
(001905)9/10/2021 8:34:03 AM - engadmin (192.168.0.62)> APPE \Utilities\Electricity\ALSB1\total_Wh\2021\9\10\UTC06.data
(001905)9/10/2021 8:34:03 AM - engadmin (192.168.0.62)> 150 Opening data channel for file upload to server of "/Utilities/Electricity/ALSB1/total_Wh/2021/9/10/UTC06.data", restarting at offset 174
(001905)9/10/2021 8:34:04 AM - engadmin (192.168.0.62)> 426 Connection closed; aborted transfer of "/Utilities/Electricity/ALSB1/total_Wh/2021/9/10/UTC06.data"

But as I said it is not too bad for me to work like this because the speed is good.

User avatar
botg
Site Admin
Posts: 35491
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

Re: Question about correct termination of datastream

#4 Post by botg » 2021-09-10 14:12

I immediately send a disconnect on the data connection when I get the 'job completed without error' signal on the data connection and get the 426 response on the control connection.
You are sending the wrong kind of disconnect. Don't abort the connection, close it. FIN, not RST.

MaartenPl
500 Command not understood
Posts: 4
Joined: 2021-09-03 06:47
First name: Maarten
Last name: PL

Re: Question about correct termination of datastream

#5 Post by MaartenPl » 2021-09-27 13:45

Well, in the PLC, I can't define the kind of disconnect.
I just call the Tdiscon block like in the attachment.
But as I said, I am happy how it is now.

Thanks!
Attachments
tdiscon.jpg
tdiscon.jpg (60.12 KiB) Viewed 1128 times

User avatar
botg
Site Admin
Posts: 35491
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

Re: Question about correct termination of datastream

#6 Post by botg » 2021-09-27 16:47

I don't understand this block diagram. What do you do in source code?

MaartenPl
500 Command not understood
Posts: 4
Joined: 2021-09-03 06:47
First name: Maarten
Last name: PL

Re: Question about correct termination of datastream

#7 Post by MaartenPl » 2021-09-28 07:40

The Tdiscon block is a system block provided by the PLC.
We can't make our own. A PLC is not a PC.

Post Reply