Please answer these questions before submitting your issue. Thanks!
php -v and php --ri swoole)swoole
swoole support => enabled
Version => 2.1.3
Author => tianfeng.han[email: [email protected]]
coroutine => enabled
epoll => enabled
eventfd => enabled
timerfd => enabled
signalfd => enabled
cpu affinity => enabled
spinlock => enabled
rwlock => enabled
async http/websocket client => enabled
Linux Native AIO => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
Which release version of this package are you using?
2.3.4
What did you do? If possible, provide a recipe for reproducing the error.
SomeController@show
$response = new \Symfony\Component\HttpFoundation\StreamedResponse(function() {
echo 'test';
}, 200, []);
return $response->send();
What did you expect to see?
The string "test" being echoed. (code works with nginx/php-fpm)
What did you see instead?
0 bytes are returned and server returns a 500.
Hi @mfauveau ,
Thanks for your bug report. I'm working on fixing it.
Hi @mfauveau ,
I fixed it in the commit https://github.com/swooletw/laravel-swoole/commit/e63e9d3198398f749e97cc6ce97924c0125a964c, and will merge into the next release.
However, the streamed response is synchronous now, so it's not recommended to do some heavy output in the response.
I am considering to make it asynchronous in the future.
This fix has been merged into the newest release.
Hi @albertcht, thanks for the fixing this so quickly! What would it take to make it asynchronous?
Hi @joecohens ,
Basically you can push stream response to a Swoole task queue. The task delivering is totally asynchronous, but the process in task worker is still synchronous. At least it will not block the normal worker process.
Or you can create a process for stream response, and bind it to Swoole event, after the process is done, destroy the event binding. But in this way will consume more CPU resource.
So I'm still trying to find a balance.