Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout issue when sending large files in the public_folder and over http_sendfile #154

Open
Ortmanns-Koeppern opened this issue Jul 16, 2024 · 1 comment

Comments

@Ortmanns-Koeppern
Copy link

Problem

When sending files either by downloading them from the public folder as well as using the http_sendfile2 function, the timeout still applies to the request and cancels it if the download takes longer than the timeout allows.

Solutions/Workarounds

Although this problem can be mitigated by setting the timeout in general or the timeout for the specific request to a long duration, this solution can still cause problems because it would not dynamically adapt to the bandwidth of different clients. Another solution could be to use fio_touch, but I did not implement a working example for this approach.

Setup

  • Raspberry Pi 5 with Raspberry Pi OS (debian bookworm port) 64 bit
  • facil io version 0.7.6
  • C compiler: gcc 12.2.0 "cc (Debian 12.2.0-14) 12.2.0"
  • C linker: cc ld.bfd 2.40
  • Using meson build

Running fio with (could add the long timeout for the mentioned solution)

// listen on port 3000 and any available network binding (NULL == 0.0.0.0)
http_listen("3000", NULL,
            .on_request = on_request,
            .on_upgrade = on_http_upgrade,
            .log = loglevel,
            .public_folder = public_folder);
// start the server
fio_start(.threads = 2);

Sending files with this function

char *p = "testfile.bin";
// http_s *req
if(http_sendfile2(req, p, strlen(p), NULL, 0)) {
  http_send_error(req, 404);
  FIO_LOG_WARNING("Can't read file %s", p);
  return 1;
}

Notes

I am not that experienced with the library. If i missed any functionality or setup to solve this problem please let me know.

@boazsegev
Copy link
Owner

Hi,

Thank you for opening this issue.

I am currently busy working on the 0.8.0 version and it took me a while to notice this thread, sorry about that.

I am unsure as what would cause this issue. How big is the file you're sending? I will try on my machine.

Also, could you please try this on your local machine with throttling on the browser?

I suspect this might be a "slow client" issue, where the buffer is full and awaiting a client to read from the buffer.

Thanks,
B.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants