FTP node put empty files to the FTP server

Hi everybody,
I am a newbie with Node-Red.
I have a flow that create a csv file starting from the data contained in a payload from an instrument, save the csv in the local machine with a custom name (xxxx_datetime.csv) and should send it to an FTP server.
My problem is that once the file is created, the file I receive at the FTP server is empty.
It looks like that the file I create is not closed or something, becuase if I try the flow putting to the FTP server a previosly created file, I have no problem.
Could anyone suggest me a solution?
I'm using node-red-contrib-ftp node


Assuming you are using the File Out node, did you see this comment in the info tab for the node " If msg.filename is used the file will be closed after every write"?

Hi Colin,
no, I did not see it.
I am using msg.filename to create the file, but I notice that is I use the same msg.filename ad msg.LocalFilename in the ftp node to identify the file to by sent, I have the problem I described above. This means that I have a function generating the msg.filename everytime I get a message from my instrument, and the same function populate the msg.localfilename for the ftp with a some seconds of delay.
Conversely, If I manually write the msg.LocalFilename directly in the ftp node, looking for an older file, I have no problem.
Any hint?

Sorry, I can't make sense of that post. For it to close the file you must use msg.filename to pass the name to the file node to tell it to close the file. If you think that is what you are doing then show us the output of a debug node showing what is going into the file node. Set the debug node to Show Complete Message.
Are you waiting for the file out node to complete before passing the message to the ftp node?

this is the complete message arriving to the File Out node:
{ "tmst": 1098249660, "chan": 6, "rfch": 1, "freq": 867.7, "stat": 1, "modu": "LORA", "datr": "SF12BW125", "codr": "4/5", "lsnr": 10.8, "rssi": -36, "opts": "", "size": 12, "fcnt": 0, "cls": 0, "port": 1, "mhdr": "405a942401800000", "appeui": "f0-ca-f0-ca-f0-ca-f0-ca", "deveui": "00-80-00-00-00-00-e3-e5", "ack": false, "adr": true, "gweui": "00-80-00-00-a0-00-4d-81", "seqn": 0, "time": "2020-02-14T15:06:08.977081Z", "payload": "1;1;2020-02-14T15:06:08.977081Z;38.855767;0;00-80-00-00-00-00-e3-e5\n1;2;2020-02-14T15:06:08.977081Z;3.02;0;00-80-00-00-00-00-e3-e5", "eui": "00-80-00-00-00-00-e3-e5", "_msgid": "e70f7541.18f088", "filename": "/home/xxx/Data/xxx_202002141606.csv", "ch1": "1a", "devicetype": "Sensore Analogico", "periferica": 1, "canalesensor": 1, "canalebat": 2, "error_hex": "00", "error": 0, "bat_hex": "0070", "bat": "3.02", "valAD_hex": "00637884", "val_elect": "38.855767" }

I'm then using "filename": "/home/xxx/Data/xxx_202002141606.csv" as ftp.localfilename with a 10 seconds delay.

If you use a file in node instead of the ftp node and read the file back is it ok?

Hi Colin,
I think I solve the problem. As You pointed, the file is correctly close, but there was a wrong setting in the ftp node that was the reason for the empty file.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.