This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

FTPS example
#21
you can see in the image that the two backups are totally different.
the before was done with the old script.
the after with the new.
Intuitively something is missing from the after

Attached Files Thumbnail(s)
   
Reply
#22
Hi all,
same problem here with FTPS, file uploaded but 0 K

FTP upload error: closed

HW: LM5 Lite (i.MX6)
SW: 20230607

Any tips?

Code:
host = 'xxx'
user = 'xxx'
pass = 'xxx'

path = '/backup' .. os.date('%Y-%m-%d') .. '.gz'

ftp = require('socket.ftp')
ltn12 = require('ltn12')
webrequest = require('webrequest')
data = webrequest('general', 'backup')

res, err = ftp.put({
  host = host,
  user = user,
  password = pass,
  secure = true,     -- without this: FTP upload error: 530 Non-anonymous sessions must use encryption.
  datasecure = true, -- without this: FTP upload error: 522 Data connections must be encrypted.
  type = "a",        -- no luck with type = "a" or type = "i"
  argument = path,
  source = ltn12.source.string(data)
})

if not res then
  alert('FTP upload error: %s', tostring(err))
end
Reply
#23
Check FTP server logs and try removing / from the file path.
Reply
#24
thanks Admin,
I have already tried removing / from file path but no change.

I don't manage the FTP server but I can try asking for the log...
Reply
#25
This is the server side log.

The guy who manages the FTP server didn't give me much information but it seems that by putting require_ssl_reuse=NO in the vsftpd.conf configuration file and maybe some firewall tweaks, the backup file is entirely transferred but always with this error: 426 Failure reading network stream.

Now if I try to send a 2 MB .csv file with this code, I always get a file truncated to multiples of 8192 and I need advice on how to correctly send a file via FTPS.

thanks for your patience

Code:
-- ...
data = io.readfile('filename.csv')
  path = ('/' .. filename)
  res, err = ftp.put({
  host = host,
  user = user,
  password = pass,
  argument = path,
  type = "a",
  secure = true,
  datasecure = true,
  source = ltn12.source.string(data)
  })

Attached Files Thumbnail(s)
   
Reply
#26
Try adding reusesession = true, to the parameters table.
Reply
#27
Ignoring the 426 error for now,
with require_ssl_reuse=NO inserted in the server configuration file vsftpd.conf the backup file is transferred entirely.

Now I need to send some 2 MB .csv files (or even a compressed ones) with the above code but I always get corrupted files as they are truncated to multiples of 8192 and I don't understand why.
No problem with smaller files
Reply


Forum Jump: