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

Swoole in HTTP/2 mode is incompatible with chunking large responses in SwooleClient #873

Closed
Shkeats opened this issue Apr 18, 2024 · 1 comment · Fixed by #875
Closed

Comments

@Shkeats
Copy link

Shkeats commented Apr 18, 2024

Octane Version

2.3.7

Laravel Version

11.4.0

PHP Version

8.3.6

What server type are you using?

Swoole

Server Version

5.1.1

Database Driver & Version

No response

Description

When running Octane with Swoole (no reverse proxy in place) and the open_http2_protocol option set to true, responses larger than the chunk size 148576 defined in Laravel\Octane\Swoole\SwooleClient cause an ErrorException to be thrown by Swoole warning that the HTTP2 client does not not support HTTP-CHUNK. Smaller responses work normally and are HTTP2 which is great.

You can see this check happening inside the swoole source https://github.com/swoole/swoole-src/blob/db5682748d8fef4dfc5c39b4d81328ebd346f5ad/ext-src/swoole_http_response.cc#L318

I couldn't find anywhere that you can access from within PHP to tell if a SwooleResponse is going to be HTTP/2 but this could probably be fixed with a simple config check (example below) as a good enough solution.

If you need more info or a repro repo, happy to provide. Also happy to do the PR with a fix just thought someone should review the issue first in case I'm missing anything.

ErrorException: Swoole\Http\Response::write(): HTTP2 client does not support HTTP-CHUNK in /var/www/html/vendor/laravel/octane/src/Swoole/SwooleClient.php:252
Stack trace:
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}()
#2 /var/www/html/vendor/laravel/octane/src/Swoole/SwooleClient.php(252): Swoole\Http\Response->write()
#3 /var/www/html/vendor/laravel/octane/src/Swoole/SwooleClient.php(146): Laravel\Octane\Swoole\SwooleClient->sendResponseContent()
#4 /var/www/html/vendor/laravel/octane/src/Worker.php(93): Laravel\Octane\Swoole\SwooleClient->respond()
#5 /var/www/html/vendor/laravel/octane/bin/swoole-server(120): Laravel\Octane\Worker->handle()
#6 [internal function]: {closure}()
#7 /var/www/html/vendor/laravel/octane/bin/swoole-server(170): Swoole\Server->start()
#8 {main}

image

image

Steps To Reproduce

Routes:

image

octane.php Swoole config:

image

@driesvints
Copy link
Member

@sy-records would you perhaps have some time to look into this one? Greatly appreciated 🙏

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

Successfully merging a pull request may close this issue.

2 participants