Using the :ftp module from erlang I am uploading to an FTPS server running vsFTPd with TLS. It is working but it seemed to have reliability issues. To test it I ran
results = 1..1_000 |> Enum.map(&("testing_#{&1}.txt")) |> Enum.map(fn name ->
FileTransfer.Ftps.upload("testing text", name, directory, config)
end) |> Enum.reject(fn res ->
res == :ok
end)
This resulted in a list of 45 elements all containing error: :trans_neg_compl
. I’ve been searching around trying to figure out what this error message means but the closest thing I can find is this https://github.com/yrashk/erlang/blob/master/lib/inets/src/ftp/ftp_response.erl which isn’t very helpful (to me at least).
This is what my FileTransfer.Ftps module looks like (Stripped down but same :ftp module function calls).
defmodule FileTransfer.Ftps do
def upload(content, file_name, dest_dir, config) do
host = to_charlist(config.host)
username = to_charlist(config.user)
password = to_charlist(config.password)
with {:ok, ftp_client} <- :ftp.open(host, tls: []),
:ok <- :ftp.user(ftp_client, username, password) do
file_path = directory |> Path.join(file_name) |> to_charlist()
:ftp.send_bin(ftp_client, file_content, file_path)
:ftp.close(ftp_client)
end
end
end
If anyone could help me figure out what is going on here it would be appreciated. Without knowing where the :trans_neg_compl message is coming from I don’t know where to start looking for the issue.