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

Concurrent file uploads hang when using HTTPS #1074

Open
pafael opened this issue Oct 8, 2024 · 4 comments
Open

Concurrent file uploads hang when using HTTPS #1074

pafael opened this issue Oct 8, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@pafael
Copy link

pafael commented Oct 8, 2024

What happened?

I'm experiencing an issue where concurrent file uploads hang indefinitely when querying the site via https.
Below is a super basic demonstration.
It occurs with as few as 20 files depending on the machine and build type.
Increasing the max_requests or the number of threads doesn't seem to help.
It doesn't happen without https, or on a regular apache web server with https.
Most of the time no error is shown in the logs, but I did get a go panic output once, not sure if it's related to this issue though...

Build Type

I tried both the docker version v1.2.5 (dunglas/frankenphp:latest) and the official static build with the same result, in worker mode (with octane) or not.

Operating system

Same problem both on my machine (WSL Ubuntu-22.04 x86_64) in local (PHP 8.3.12), and on a VPS running on Debian 12 (amd64, PHP 8.2.23) with a public domain.

PHP Page code example

<?php
if(isset($_FILES) && count($_FILES) > 0){
    echo json_encode(['status' => 'success']);
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <body>


        <input multiple type="file" accept=".pdf"/>
        <button onclick="sendToServer()">Post files to server</button>

        <script>

           async function sendToServer() {
               const files = document.querySelector('input[type="file"]').files;
               const promises = [];
               for (let i = 0; i < files.length; i++) {
                   promises.push(postPromise(files[i]));
               }
               await Promise.all(promises);
               alert('All files uploaded');
           }

            function postPromise(file){
                return new Promise( function(resolve, reject){
                    const fd = new FormData();
                    fd.append('file', file);
                    fetch('savefile', {
                        method: 'POST',
                        body: fd
                    }).then(response => {
                       resolve(response);
                    }).catch(error => {
                       reject({
                           status: error.status,
                            statusText: error.statusText
                        });
                    });
                });
            }
        </script> 
    </body>
 </html>

Build Type

Custom (tell us more in the description)

Worker Mode

No

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

PHP Version 8.3.11

Relevant log output

panic: error during PHP script execution
goroutine 67 [running, locked to thread]:
github.com/dunglas/frankenphp.go_handle_request()
        /go/src/app/frankenphp.go:496 +0x2dd
@pafael pafael added the bug Something isn't working label Oct 8, 2024
@dunglas
Copy link
Owner

dunglas commented Oct 8, 2024

What version of HTTP are you using?

Could you try if enabling full-duplex fixed the issue? https://caddyserver.com/docs/caddyfile/options#enable-full-duplex

@pafael
Copy link
Author

pafael commented Oct 8, 2024

The requests are done with http/2.0 - for which the docs say that this enable_full_duplex option has no effect.
I tried with the following Caddyfile and indeed it doesn't seem to have any effect.

{
   frankenphp
}

https://localhost:8000 {
   root * ./public
   encode zstd br gzip
   php_server {
      resolve_root_symlink
      enable_full_duplex
   }
}

@dunglas
Copy link
Owner

dunglas commented Oct 8, 2024

Thanks. Would you be able to create a minimal reproducer (like a tiny repository with a script reproducing the issue)? This would help a lot to debug.

@pafael
Copy link
Author

pafael commented Oct 8, 2024

Sure, actually the PHP Code example of my first post is already it, but here it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants