Closed samuelnogueira closed 5 years ago
$server->set([
'buffer_output_size' => 32 * 1024 *1024, // 32M
])
If I understand it correctly you can set all server options like these in the configuration with:
'swoole-http-server' => [
'options' => [
'buffer_output_size' => 32 * 1024 *1024
]
]
Thank you @huangzhhui and @xtreamwayz , that works!
Just a note, setting buffer_output_size
to anything below\Zend\Expressive\Swoole\SwooleEmitter::CHUNK_SIZE + 10
is still not enough to prevent swoole from throwing those warnings. I'm guessing this has to do with some additional bytes being written to the output buffer by Swoole\Http\Server here: https://github.com/swoole/swoole-src/blob/cc7a013b8761383befed70a3e999310a0306ea4e/swoole_http_server.cc#L1534
Given this workaround fixes an unexpected behavior which isn't directly related with this library, should any action be taken here?
@samuelnogueira — regarding:
Given this workaround fixes an unexpected behavior which isn't directly related with this library, should any action be taken here?
I think we can direct folks to the workarounds illustrated in the comments in this issue. Alternately, file an issue upstream to the Swoole source repository.
Apparently, despite stating in Swoole documentation that
Swoole\Http\Response::write
accepts up to 2M (2097152 bytes) of data, aWARNING swServer_tcp_send (ERROR 1202): More than the output buffer size[2097152], please use the sendfile.
warning will be raised when trying to write anything more than 2097142 bytes (note the difference between 2097152 and 2097142).This happens regardless of response status code, headers, cookies and previously sent body fragments.
This isn't directly an issue with zend-expressive-swoole library, but this problem isn't neither handled by the library, or documented.
Code to reproduce the issue
Expected results
curl http://localhost:8080/
returns a bunch of a'sActual results
WARNING swServer_tcp_send (ERROR 1202): More than the output buffer size[2097152], please use the sendfile.
Plus empty HTTP response.