Hi there,
I recently deployed a FTP server on Fly using GitHub - gregmsanderson/fly-ftp-server: A simple public FTP server for Fly.io from @greg (cf. Setting up a public FTP server on Fly.io - #6 by greg).
However, after trying to configure the project, I ended up being able to FTP access the server through FileZilla, but not in my Elixir project (I’m using the :ftp module).
Here is my code:
url = "ftp://user:password@888.888.888.888/ftp"
%URI{
host: host,
scheme: "ftp",
port: port,
userinfo: userinfo,
path: path
} = URI.parse(url)
{:ok, client_pid} =
:ftp.open(host |> String.to_charlist(),
verbose: true,
timeout: 3_000,
dtimeout: 3_000
)
if userinfo do
[user, pass] = userinfo |> String.split(":")
:ok = :ftp.user(client_pid, ~c(#{user}), ~c(#{pass}))
end
IO.puts("FTP: OK 1 ")
:ok = :ftp.ls(client_pid)
IO.puts("FTP: OK 2")
And I get:
"Receiving: 220 Welcome"
"Sending: USER admin"
"Receiving: 331 Please specify the password."
"Sending: PASS ADMIN.EI.2022"
"Receiving: 230 Login successful."
"FTP: OK 1"
"Sending: PASV"
"Receiving: 227 Entering Passive Mode (172,19,0,242,82,8)."
** (MatchError) no match of right hand side value: {:error, :timeout}
I’ve never seen this 172.19...
IP address, but I guess it’s the server’s private one, which mixes things up when trying to communicate to the outer world (no idea how FileZilla manages to get around this).
So I set the ADDRESS
to the IP of my Fly server using fly secrets set ADDRESS="XX.XX.XX.XX"
). And then I get:
"Receiving: 227 Entering Passive Mode (0,0,0,0,82,8)."
** (MatchError) no match of right hand side value: {:error, :econnrefused}
So it did change the IP address, but it set it to 0.0.0.0. What am I doing wrong here? I tried using IPv6 but couldn’t get it to work either.