Opened 2 years ago

Closed 2 years ago

#2267 closed defect (worksforme)

Upload large files with Firefox via http2

Reported by: jeffrson@… Owned by:
Priority: major Milestone:
Component: nginx-core Version:
Keywords: Cc: jeffrson@…
uname -a: Linux 1baf4930be32 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) x86_64 Linux
nginx -V: nginx version: nginx/1.21.3
built by gcc 10.3.1 20210424 (Alpine 10.3.1_git20210424)
built with OpenSSL 1.1.1k 25 Mar 2021 (running with OpenSSL 1.1.1l 24 Aug 2021)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-perl_modules_path=/usr/lib/perl5/vendor_perl --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-Os -fomit-frame-pointer -g' --with-ld-opt=-Wl,--as-needed,-O1,--sort-common

Description

I use nginx (1.21.3) inside docker container (nginx:alpine) as reverse proxy. Proxied server is NodeJS Express server, upload uses multer.

For the virtual server I have http2 active:
`
listen 443 ssl http2;
listen [::]:443 ssl http2;
`

The client uploads with XMLHttpRequest. Proxying switches to Http 1.1 because I need Websockets as well.

Pages are delivered fine, small files (a few MB) will be transferred successfully with Chrome, Edge, Firefox. Larger files (some 100MB, used a file of about 900MB for final testing) however are only uploaded with Chrome or Edge (so I know that client_max_body_size a.s.o. is sufficient), *not* transferred with Firefox though.

Firefox calls the XMLHttpRequest's onerror after about 67s. But as I can see in the client's network traffic as well as in nginx debug log, there's continued data flow (client sends, nginx receives). It takes the same time, that the upload lasts on Chrome/Edge. Then nginx reports 499 error.

For Chrome as well as Firefox there are lots of such messages throughout the debug log:
2021/10/28 20:12:18 [debug] 33#33: *1 http2 read handler
2021/10/28 20:12:18 [debug] 33#33: *1 SSL_read: -1
2021/10/28 20:12:18 [debug] 33#33: *1 SSL_get_error: 2

Now, when I disable http2 in my server's conf, the 980MB file is successfully transferred with any of the three browsers. Furthermore, it takes only 2/3 of the time with active http2.

BTW, when upload is tried with Firefox (http2 enabled), nginx does not even call into the proxied server. Debug output of Express server shows nothing but loading of the actual page.

Change History (4)

comment:1 by Sergey Kandaurov, 2 years ago

Can you collect and attach entire debug log for two connections, with successful and unsuccessful transfer, with minimally sufficient file size?

comment:2 by jeffrson@…, 2 years ago

Well that's hard - I tried to create files of different size.

One test file of 255MB is always uploaded successfully. A file of 266MB always fails. However, 260MB will be sometimes transferred successfully, sometimes not.

So I have now debug logs for failing and succeeding upload. But these files are about 1.03MB in size (gzipped) - attachments allow for 256kb. What can I do now?

comment:3 by Sergey Kandaurov, 2 years ago

Limits were raised, can you try again?

comment:4 by Maxim Dounin, 2 years ago

Resolution: worksforme
Status: newclosed

Feedback timeout.

I've did a lot of testing with Firefox 96.0.3 (macOS), including file upload with form submission and via XMLHttpRequest, various files sizes up to 1.5G, different network speed so upload takes up to 60+ (or even 300+) seconds, and various nginx configurations, notably with proxying and unbuffered proxying. In all tests Firefox was able to correctly upload files via HTTP/2.

Most likely the problem originally observed is something in Firefox version the reporter was using.

Note: See TracTickets for help on using tickets.