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

Big static files are truncated when served by Raspberry pi 4 #2461

Closed
prisme60 opened this issue Feb 1, 2023 · 4 comments
Closed

Big static files are truncated when served by Raspberry pi 4 #2461

prisme60 opened this issue Feb 1, 2023 · 4 comments
Labels
triage A bug report being investigated

Comments

@prisme60
Copy link

prisme60 commented Feb 1, 2023

Description

Rocket server is not able to serve static files that make more than 211MB when running on a raspberry pi 4 with RAM 4Go.

To Reproduce

Use a raspberry pi 4 with 4 GB.

Expected Behavior

The following code is working as expected with my linux PC (ubuntu 22.10) with an AMD FX6300 Six-Core Processor (64bits). With curl or firefox on my local network with ethernet wire, I can download the entire file (4.3GB). But with the raspberry pi 4 with RAM 4GB, (compilation has been done in-situ, so no cross compilation), I can only retrieve the first 211MB.

main.rs

#[macro_use] extern crate rocket;
use rocket::fs::{FileServer, relative};

#[launch]
fn rocket() -> _ {
    rocket::build()
        .mount("/private/AaBB123/", FileServer::from(relative!("static")))

Cargo.toml

[package]
name = "serve_http_files"
version = "0.1.0"
edition = "2021"

[dependencies]
rocket = "0.5.0-rc.2"

I look into the documentation in order to check limitations, but limitations are only for upload.

Log of rocket server:

pi@pi4:~/serve_http_files $ cargo run --release
    Finished release [optimized] target(s) in 3.08s
     Running `target/release/serve_http_files`
🔧 Configured for release.
   >> address: ::
   >> port: 8080
   >> workers: 4
   >> ident: Rocket
   >> limits: bytes = 8KiB, data-form = 2MiB, file = 1MiB, form = 32KiB, json = 1MiB, msgpack = 1MiB, string = 8KiB
   >> temp dir: /tmp
   >> http/2: true
   >> keep-alive: 5s
   >> tls: disabled
   >> shutdown: ctrlc = true, force = true, signals = [SIGTERM], grace = 2s, mercy = 3s
   >> log level: debug
   >> cli colors: true
📬 Routes:
   >> (FileServer: static) GET /private/AaBB123/<path..> [10]
📡 Fairings:
   >> Shield (liftoff, response, singleton)
registering event source with poller: token=Token(0), interests=READABLE | WRITABLE
🛡 Shield:
   >> Permissions-Policy: interest-cohort=()                                                                                                                                                 
   >> X-Content-Type-Options: nosniff                                                                                                                                                        
   >> X-Frame-Options: SAMEORIGIN                                                                                                                                                            
🚀 Rocket has launched from http://[::]:8080                                                                                                                                                 
registering event source with poller: token=Token(1), interests=READABLE | WRITABLE                                                                                                          
GET /private/AaBB123/GrosFichier4.3GB.mkv:                                                                                                  
   >> Matched: (FileServer: static) GET /private/AaBB123/<path..> [10]                                                                                                                    
   >> Outcome: Success
   >> Remote left: channel closed.
deregistering event source from poller

Here the log of the curl download command :

curl http://pi4.local:8080/private/AaBB123/GrosFichier4.3GB.mkv --output /dev/null --verbose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 192.168.1.82:8080...
* Connected to pi4.local (192.168.1.82) port 8080 (#0)
> GET /private/AaBB123/GrosFichier4.3GB.mkv HTTP/1.1
> Host: pi4.local:8080
> User-Agent: curl/7.85.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< server: Rocket
< permissions-policy: interest-cohort=()
< x-content-type-options: nosniff
< x-frame-options: SAMEORIGIN
< content-length: 221864065
< date: Wed, 01 Feb 2023 20:11:58 GMT
< 
{ [1448 bytes data]
100  211M  100  211M    0     0  9579k      0  0:00:22  0:00:22 --:--:-- 9816k
* Connection #0 to host pi4.local left intact

Environment:

  • OS Distribution and Kernel: Raspbian GNU/Linux 10 (buster) Linux pi4 5.10.103-v7l+ # 1529 SMP Tue Mar 8 12:24:00 GMT 2022 armv7l GNU/Linux
  • Rocket Version: 0.5.0-rc.2
  • Rust version: 1.67.0

Additional Context

pi@pi4:~/serve_http_files $ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 28125
max locked memory       (kbytes, -l) 65536
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 28125
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
@prisme60 prisme60 added the triage A bug report being investigated label Feb 1, 2023
@prisme60
Copy link
Author

prisme60 commented Feb 4, 2023

I have done a similar test with actix_web crate on the same rapsberry pi 4, in the same conditions (same rust version, ...) and the file is fully downloaded.

@SergioBenitez
Copy link
Member

SergioBenitez commented Mar 27, 2023

That sounds really, really weird. I recall there being a tokio/Linux bug related to this not too long ago. Though actix also uses tokio, it doesn't uses Tokio's file type as Rocket does, so this could explain the discrepancy. Could you perhaps try updating your kernel as well as your dependencies (ie cargo update) and see if the issue is still present?

Edit: here's the relevant issue on tokio's end: tokio-rs/tokio#3803

@prisme60
Copy link
Author

I have upgraded to last raspberry distrib. I have installed the 64-bit version instead of the 32-bit version.
I have fully recompiled (I have launch cargo clean, so I have keep the same cargo.lock, I forget to remove it, then recompile).
It is now working as expected, i.e. no file truncation.

christian@pi4:~ $ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye
christian@pi4:~ $ uname -a
Linux pi4 5.15.84-v8+ #1613 SMP PREEMPT Thu Jan 5 12:03:08 GMT 2023 aarch64 GNU/Linux

So I am totally agree with you that there is a problem with this kernel version.

Thank you for your support.

@SergioBenitez
Copy link
Member

Excellent. Glad to hear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage A bug report being investigated
Projects
None yet
Development

No branches or pull requests

2 participants