rlopzc

rlopzc

Learn how to leverage Erlang + Elixir’s GenServer to build a robust FTP Client.

https://rlopzc.com/posts/elixir-ftp-client-genserver-part-1/

Showing Posts 1 to 6

mudasobwa

mudasobwa

Creator of Cure

Well put! The only thing that bugs me is this code would suffer crashes operating against slow ftp servers. The code below would blow up if there is no response for :ftp.ls/0 is 5 seconds.

def ls do
  GenServer.call({:global, __MODULE__}, :ls)
end

I would probably put a greater timeout or even :infinity there.

D4no0

D4no0

Damn, this is like a blast from the past. We were using ftp for one of our projects back in the day, nasty stuff when it stops working silently.

The approach we took back then was to check for files every 1 minute. What we did differently was that we would establish a new connection every-time and close when done, this builds a layer of fault-tolerance because we were interacting with different ftp servers, different versions and OS, and sometimes they would start behaving weirdly for no reason.

rlopzc

rlopzc OP

Thanks!!

Uff this is a hard one because it can block the calling process infinity.

rlopzc

rlopzc OP

Were you able to use mode: :active during that time? I’ve done some experiments but can’t get the active mode to work (receiving data as messages).

D4no0

D4no0

No, we were strictly using passive mode, it would be extremely annoying to set the infrastructure to allow incoming connections.

We did have an issue where data transfer would not work. There was a misconfigured ftp server behind a proxy that would send its local IP for data connections, but send the correct public one for commands, so it would work until you wanted to make file transfers. What I ended up doing was to extract the ftp library from OTP, mass rename it and change the library to always fetch the IP from the initial command connection for data connections.

I don’t remember exactly how I found out the exact issue, but I think it was by running ftp in verbose mode, it literally shows all the steps it takes if I remember correctly.

adamu

adamu

I think it would be useful to include automated tests, as especially for clients and GenServers, this is likely to considerably change the design.

— All posts loaded —

Where Next? Top

Trending in Blog Posts Top

bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
pckrishnadas88
Hey everyone! :waving_hand: I’ve published Part 7 of the Building Distributed Systems in Elixir series, where we build core distributed ...
New
zorn
An educational side project in Elixir, Phoenix, and Tauri. I share what I learned while wiring Automerge into the BEAM, including how I s...
New
mudasobwa
So, instead of wasting my afternoon arguing with anonymous handles on X, I turned to my trusty, soulless assistant and said: “Listen, ple...
New
nathanl
Process labels are useful for visualization and debugging. Here’s why you should use them.
New
abreujp
New article: Elixir Project Structure — From mix new to a Growing Codebase I’ve published a new article in my Elixir learning series on d...
New
andreasronge
What happens if you design tools for LLMs instead of letting LLM use human tools ? Wrote a blog on why and what that enables. As I see ...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews