clemensm

clemensm

Hi everyone

I’ve got a somewhat unique question on how to continue debugging, this is probably mainly interesting for the people who know the in- and outs of the bandit http server.

So the situation is as following: I’m using a Mac with the new ARM chips for development. Recently I wanted to have a closer look at containers using podman and check out if I can use them for local development as well. The idea here was to mount my local elixir project folder into the container, so that I could run my editor etc from my native machine and would only use the container for compiling and controlling the elixir version.

However given that using the native option of podman that runs a Fedora Linux using QEMU is just as slow as using docker with the same setup, I decided to try to use the podman remote feature, where you can basically use any Linux machine that you can access using ssh as your “local” podman backend. And in this case I wanted to use a Fedora server hosted in Paralles, given how fast access to the hosts file system is in Parallels.

Now basically this all works as expected (some more setup is required, but that is not really relevant here), with the notable exception that I cannot serve static files like app.js at all. If I try to e.g. fetch the file using curl, even from inside the container, the download never starts and curl gives me an error like this:

curl: (18) transfer closed with 783282 bytes remaining to read

So after some more testing I’ve found out that this only happens on shared folders from my Mac host, but not if I create a new project inside the container itself. In the latter case this works fine.

I’ve now tried to debug this, however I can’t seem to find what kind of debugging I can activate that will help me futher. I’ve tried using the Bandit.Logger.attach_logger() functions, but those do not give any helpfull output. I’ve also tried to add dbg statements in various parts of the Bandit and ThousandIlands packages, however the last place I could trace was the ThousandIsland.Handler.handle_continuation function, which seems to return normally. So what ever happens must be happening later.

Can anyone give me a pointer if I can somehow check if mabye Erlang is unable to write the file to the socket, or something like that?

Thanks already for any help, it would be really nice if I could get this to work :slight_smile:

Showing Posts 1 to 5

clemensm

clemensm OP

Some more info from my side, I’ve setup a simple nginx server on the parallels VM and tried to serve the files on the shared folder using that, and I get the same error/problem. So it seems that this is not related to elixir or Erlang in any way, but is a problem with how the shared folders are handled by Parallels.

Thanks anyway!

clemensm

clemensm OP

Hmm, some more info I’ve found. So first, using nginx, I’ve disabled SELinux, though I’m not sure that was really necessary. And after some more digging around, I’ve finally been able to send the file using nginx by setting the sendfile option of nginx to off.

According to the nginx documentation what this does is, it does not load the file into the buffer before sending it, but rather sends it directly from disk.

So the question now is: Is there an option in Bandit or in Erlang that can be used to turn this off as well?

clemensm

clemensm OP

In case anyone finds this in the future and is interested in a possible solution:

After a lot of digging around in the Bandit sources, then the Thousand Island sources, then the :file, :gen_tcp and :socket modules, I think there is no option to do this in Erlang and the BEAM without modifying the actual C bindings to the network stack…

But I did come up with a workaround for local development and written a long blog post about how to set everything up:

Or jump directly here for the actual solution:

hkrutzer

hkrutzer

A bit offtopic, but https://orbstack.dev has good performance compared to other solutions. It doesn’t run podman but I don’t think that matters for development as the same containers should be able to run on either Podman or Docker.

clemensm

clemensm OP

Thanks, never heard of that. I’ll check it out, though I always prefer to be as close as possible to my production environment regarding tools etc as possible.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
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
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews