Giter Site home page Giter Site logo

k911 / swoole-bundle Goto Github PK

View Code? Open in Web Editor NEW
256.0 256.0 45.0 2.69 MB

Symfony Swoole Bundle

License: MIT License

PHP 97.47% Shell 0.21% JavaScript 0.13% Dockerfile 1.62% Makefile 0.13% HCL 0.39% Twig 0.04%
async hacktoberfest http-server php swoole symfony-bundle

swoole-bundle's People

Contributors

coderchang65535 avatar dependabot-preview[bot] avatar enumag avatar fjogeleit avatar jderusse avatar k911 avatar luca-nardelli avatar mab05k avatar rastusik avatar supersmile2009 avatar swoole-bundle-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swoole-bundle's Issues

Bundles seems to skip firewalls

Describe the bug
The bundle seems to "skip"the user authentication process in symfony.
In my security.yaml I have

    firewalls:
        main:
            stateless: true
            anonymous: true
            provider: my_custom_user_provider
            guard:
                authenticators:
                    - App\Security\MyCustomGuard

so when I send a request like this where xxx.xxx.xxx is a valid jwt token, I successfully get a response
curl --location --request GET 'http://localhost/someresource/031abb40-a76c-11eb-aacc-0242ac120003' \ --header 'Authorization: Bearer xxx.xxx.xxx'

but when I send another request just after with, where yyy.yyy.yyy is not a valid token the user should be denied access whereas what I get is the previous response
curl --location --request GET 'http://localhost/someresource/031abb40-a76c-11eb-aacc-0242ac120003' \ --header 'Authorization: Bearer yyy.yyy.yyy'

If I stop and restart the swoole server and resend
curl --location --request GET 'http://localhost/someresource/031abb40-a76c-11eb-aacc-0242ac120003' \ --header 'Authorization: Bearer yyy.yyy.yyy'
I then have an access denied

Steps To Reproduce
Try to use a user provider and security with stateless and anonymous set to true in a symfony app with an authentication mechanism based on Authorization http headers.

Expected behavior
When I send a second request with an invalid authorization token I expect that to pass first via the security layer I declare in my symfony app (that is the behaviour I have using the same app with php-fpm).

Environment (please complete the following information):

  • OS: Linux
  • PHP Version: 7.3
  • Swoole Version: 4.6.6
  • Symfony Version: 4.4.16
  • Running in docker: Yes

Additional context
Note: I have already seen #489 and I am following already this example https://github.com/k911/swoole-bundle/blob/develop/tests/Fixtures/Symfony/app/config/session/swoole.yaml

Use cooperative scheduling in request handling by enabling swoole coroutine hooks for IO functions

Is your feature request related to a problem? Please describe.
Current architecture of the swoole bundle expects the swoole http server process to handle exactly one request at once. I would like to enable cooperative scheduling by enabling the swoole IO functions coroutine hooks to be able to handle multiple requests concurrently, as the usage if Swoole was intended by design.

Describe the solution you'd like
The bundle should have a configuration option (e.g. cooperative_scheduling) which would enable concurrent request processing. I'm currently doing research and figuring out how to do it, I've identified these pin points:

  • to be able to use standard Syfony and Doctrine code, Swoole hooks for PHP IO functions need to be enabled (https://www.swoole.co.uk/docs/modules/swoole-coroutine-enableCoroutine)
  • a context manager for stateful Symfony services in DI container needs to be implemented (something like this https://www.swoole.co.uk/article/isolating-variables-with-coroutine-context)
  • maybe there should be some kind of concurrent request limiter implemented so php wouldn't run out of memory, but I'm not sure yet... or at least the default memory limit should be higher as usual, because in this mode, only one swoole web process should be sufficient to squeeze out the complete performance of a CPU core instead of multiple processes in the current implementation

Describe alternatives you've considered
I don't see any alternatives here, except the current implementation, feel free to discuss

Additional context
Nope

Replace entity manager handler with doctrine resettable em bundle

Is your feature request related to a problem? Please describe.
The problem of the implemented entity manager handler is, that when an exception occurs in the entity manager, it gets closed and it won't be reset automatically.

Describe the solution you'd like
I've implemented a resettable entity manager handler in this bundle: https://github.com/pixelfederation/doctrine-resettable-em-bundle . I would like to remove the current entity manager handler and suggest to integrate the bundle.

Describe alternatives you've considered
Normally I would just made a pull request to get the bundle's code into this swoole bundle, but the problem is, that I needed the resetting outside of swoole bundle (in Symfony Messenger worker context) .

What do you think, @k911 ?

In addition to that (not sure whether I should open another issue, so I'm briefly mentioning it here) - I have a fork of your repository (https://github.com/pixelfederation/swoole-bundle) and I would like to port the features from the fork into your bundle. Feature after feature, separately, so the process and the features are understandable. What do you think about that? I couldn't do it before, because I needed to make some experiments and get our app up and running, so it was faster to proceed separately.

Roadmap

  • Hot code-reload on dev env (#12) [linux / with inotify]
    • Reload symfony kernel / DI container (or check if it is possible?)
    • Reload on macOs (fsevents)
  • Demonize option (#8)
  • Integration with symfony/messenger (executing tasks / task handlers) (#56
  • Gathering workers stats (#32)
  • Run tests in containers (#39)
  • Gather code coverage from test suites in containers (#45)
  • Stabilize code coverage / do not use xdebug (switched to pcov in #50)
  • Safe integration with Symfony Session (see #6, added in #73)
  • Log exceptions in top-level ExceptionHandler (#79)
  • Enhance logging (integration with Monolog Bundle; log channels; configurable access logs)
  • Refactor server listeners initialization and configuration (being worked on feat/dynamic-listeners branch)
    • Dual-stack TCP listener by default
    • HTTP2 & TLS/SSL support
    • Insecure TLS by default if cert is not provided
    • WebSocket server
  • PSR 6/16 compatible Cache with Swoole\Table
  • Build docker images on CI with Buildx/BuildKit (see #208)

hot reload not work

Describe the bug

i have installed inotify and enabled it in symfony, but when i change php file, the change is not reflected.

static: advanced
hmr: inotify

Environment (please complete the following information):

  • OS: macOs
  • PHP Version: 7.4.2
  • Swoole Version: latest
  • Symfony Version: 5
  • Running in docker: Yes

Additional context
I have set AUTORELOAD_ANY_FILES=1 in docker-compose

volumes:
      - ../:/var/www/app
      - ./data/shell_history:/home/utente/shell_history
    networks:
      - network_app
    environment:
      - HISTFILE=/home/utente/shell_history/.zsh_history
      - SWOOLE_TIMEZONE=Europe/Rome
      - DISABLE_DEFAULT_SERVER=1
      - AUTORELOAD_PROGRAMS="swoole"
      - AUTORELOAD_ANY_FILES="yes"
      - PHP_IDE_CONFIG="serverName=application"
      - XDEBUG_CONFIG="idekey=PHPSTORM remote_host=host.docker.internal remote_port=9000"

Fallback to Symfony error handler on error or exception

Is your feature request related to a problem? Please describe.
Current ProductionExceptionHandler is too simple. It would be better if the bundle exception handler would be able to work with Symfony exception/error handler to display messages in Symfony style.

Describe the solution you'd like
I would like to modify the ProductionExceptionHandler to use the Symfony error/exception handlers.

Describe alternatives you've considered
I haven't considered other alternatives, since I already have a working implementation

Additional context
The point is to be able to have Symfony error messages in DEV environment and a generic error message (preferably from Symfony) in PROD.

The running server takes all the resources of one core of the CPU.

When I started the app server using bin/console swoole:server:run, I've got load average of a core of a processor in 100%. At the same time, I do not make requests to the site.

%Cpu(s): 13,2 us,  1,3 sy,  0,0 ni, 85,5 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st
КиБ Mem : 24515392 total, 14220344 free,  4905336 used,  5389712 buff/cache
КиБ Swap:  9765884 total,  9765884 free,        0 used. 18783208 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                    
14258 yanak     20   0  381220  51752  28124 R 100,0  0,2   0:38.10 php                                                                        

My swoole version is

swoole

swoole support => enabled
Version => 4.2.11
Author => Swoole Group[email: [email protected]]
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.enable_coroutine => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
swoole.use_shortname => On => On

My php version is

PHP 7.2.13-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Dec  7 2018 08:07:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.13-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans

Also I tried https://github.com/zendframework/zend-expressive-swoole and it works fine with zend expressive. The load average of CPU was low in idle mode.

Swoole 4.5 support?

Initially I wanted to report that swoole-bundle couldn't install due to "missing ext-swoole". but I have it installed it correctly.

when getting ready to submit the issue, I saw in the preview that this bundle expected swoole ~4.4.7 and I have swoole 4.5.0 (installed via pecl).

Signals don't work when XdebugHandler restarts process

XdebugHandler restarts cli process and don't pass the signals to the child process.

Example:

  1. Run server with swoole:server:run command
  2. Click CONTROL-C
  3. Scripts exits immediately without "Swoole HTTP Server has been successfully shutdown.".

It might be needed to use another approach for disabling Xdebug. (Symfony/Process?)

Add more commands

  • swoole:server:start - Start swoole server in background (#8)
  • swoole:server:stop (#8)
  • swoole:server:reload (#8)
  • swoole:server:status (#32)

Array of Response Headers

Describe the bug
Cannot return multiple response headers. For example, my Symfony response has the Vary header set with an array of items ['Content-Type', 'Authorization', 'Origin']. The following code snippet from
https://github.com/k911/swoole-bundle/blob/develop/src/Bridge/Symfony/HttpFoundation/ResponseProcessor.php#L25-L27 will create a Swoole response with only one Vary header: Vary: Origin.

Steps To Reproduce
Create a Symfony response that returns an array of HTTP Header

Expected behavior
In my scenario, the Vary Header should be Vary: Content-Type, Authorization, Origin

Environment (please complete the following information):

  • OS: Alpine Linux
  • PHP Version: 7.3-cli-alpine3.10
  • Swoole Version: 4.4.12
  • Symfony Version: 4.4.4
  • Running in docker: Yes

Additional context
Running in Docker

Logs
No relevant logs.

Different Voter Result

Describe the bug
Different Voter Result Between Conventional, Road Runner and Swoole Bundle

Steps To Reproduce
I use this repo https://github.com/KejawenLab/SemartApiSkeleton (using docker) and add swoole bundle, and i dont add any configuration, just default and then run the aplication using swoole server

Expected behavior
The Voter return GRANTED

Result in Nginx and Roud Runner Bundle
Screenshot from 2021-03-25 22-05-49

Result in Swoole Bundle
Screenshot from 2021-04-01 15-32-49

Screenshot from 2021-04-01 15-34-22

The authenticator is returned User Entity as Espected and the ROLE_USER is setted but in Swoole, the Voter returned DENIED

Symfony (http foundation) request->getRequestUri() doesn't contain query string

Describe the bug
The creation of Http Request in the RequestFactory doesn't set the $_SERVER[REQUEST_URI] parameter to the $server variable, which results in wrong value returned by calling $request->getRequestUri().

Steps To Reproduce
When a Symfony app with swoole bundle with gets requested with an url like this: http://localhost:9501/twig?test=abc&wtf=123, calling $request->getRequestUri() somewhere in the code, will return '/twig'.

Expected behavior
The method call should return this value: /twig?test=abc&wtf=123

Reference in symfony's Http/Request code: https://github.com/symfony/http-foundation/blob/1b66b861f3ff55fb39c13822a0fc915018b5ac84/Request.php#L1005

Environment (please complete the following information):

  • OS: Linux
  • PHP Version: 7.3.15
  • Swoole Version: 4.4.8
  • Symfony Version: 5.1.1
  • Running in docker: Yes

Proposed fix
The bug happens because this line: https://github.com/symfony/http-foundation/blob/v5.1.1/Request.php#L413 isn't called by creating the Request instance in the RequestsFactory

One solution would be to add these two lines into the factory:

$queryString = $server['QUERY_STRING'] ?? '';
$server['REQUEST_URI'] = $server['REQUEST_URI'] . ($queryString !== '' ? '?' . $queryString : '');

Another solution would be to call Request::create(), instead of just calling the Request class constructor directly.

How to fix error handling?

I tried to add this to my application. It seems to work fine while everything is running smoothly. The problem is that when a request causes an PHP error then the client never receives any kind of response - no error code 500, no debug information. The browser actually thinks the request did not finish even though it did.

Can you give me some advice how to handle this or at least where to look while trying to fix it? When I understand it I can help with writing some docs about it or maybe sending a PR if it is a small fix.

Introduce Infection in CI Pipeline

Is your feature request related to a problem? Please describe.
Use infection to run the mutation testing suite

Describe the solution you'd like
Install and configure infection/infection

Slow response time

Describe the bug
I have done some comparaison between running nginx + fpm vs swoole with FostHtppCacheBundle.
on locale with fpm, I have response time never go over 18ms to serve a simple cached json result which is stored in a file on the disk.

On the other hand. for the same call on swoole it take 28ms minimum up to 40ms.

So fpm seem lot twice faster.

Do you know any tweek I can do to improve swoole response time?

Environment (please complete the following information):

  • OS: Mac
  • PHP Version: 7.3.13
  • Symfony Version: 4.4
  • Running in docker: No
  • opcache: enabled

AdvancedStaticFileServer should fallback to mime type text/plain on when serving unknown file extension

Is your feature request related to a problem? Please describe.
Current behaviour with AdvancedStaticFileServer doesn't serve requested static file when the requested file has an extension unknown to the AdvancedStaticFileServer, but proxies the request to the symfony kernel.

Describe the solution you'd like
I suggest to treat file extensions unknown to the AdvancedStaticFileServer configuration by default as text/plain, so the requested file would be served to the client, even though with the wrong mime type.
Alternatively I suggest to make the AdvancedStaticFileServer mime types configurable using symfony config mechanism, to be able to add custom mime types (e.g. sqlite, which I need to serve in my project).

Errors when setting worker_count and reactor+count through ENV

Describe the bug
Symfony app fails to start with settings such as this:

parameters:
    env(WORKER_COUNT): 4
    env(REACTOR_COUNT): 2

swoole:
    http_server:
        settings:
            worker_count: '%env(int:WORKER_COUNT)%'
            reactor_count: '%env(int:REACTOR_COUNT)%'

with this error: The value 0 is too small for path "swoole.http_server.settings.worker_count". Should be greater than or equal to 1

Steps To Reproduce
already mentioned

Expected behavior
Symfony app starts normally

The fix is to change the corresponding nodes in Configuration class from integerNode to scalarNode. I'm creating the fix right now.

Create test suite

  • Create simple symfony application in tests/
  • Run feature tests on travis
  • Combine code coverage from unit / feature tests

Unable to upgrade to v0.8.3 on PHP 8.0 due to assertion BC break

Is your feature request related to a problem? Please describe.
Installation of this package does not work with php 8
(beberlei/assert[v3.0.0, ..., v3.2.7] require php ^7 -> your php version (8.0.1) does not satisfy that requirement.)

Describe the solution you'd like
Merge #417

Profiler toolbar doesn't collect logs

Describe the bug
Symfony profiler (debug toolbar) doesn't collect logs with symfony-swoole

Steps To Reproduce
Enable the profiler toolbar and try to log something during a profiled request. When going to the request profile from the toolbar, the Logs menu item doesn't contain any data.

Expected behavior
There should be data in the logs menu item.

header already sent exception when session_start

When running under swoole, header_sent() always returns true and headers_list() returns null.
Session start throws an exception. It has nothing to do with the session storage driver, native\pdo both have this problem.

Reduce PHP/Symfony Memory leaks

First, I have to say this is amazing bundle. I really love it, speed diff is really big and my next project will definitely use it.

I do however have an issue. When used under FPM, I get this:

image

73ms, 2MB consistent.

But under this bundle:

image

First request is 16MB but it keeps pilling. This is from blank Symfony project with just 1 route (default).
Any idea what is happening?

The problem is that I used this bundle in a real project where memory was over 80MB and it was actually slower than FPM.


Another update:

I made HMR to work. Speed increase is really big, can't wait to put it live!

HMR and server reload don't work

Describe the bug
The symfony project itself works fine and as expected. But the HRM doesn't work. I have to stop and start the swoole-server every time I change a file. Did I something wrong? The InotifyHRM class is loaded and initialized.

For my opinion problem here
https://github.com/k911/swoole-bundle/blob/develop/src/Server/Runtime/HMR/InotifyHMR.php#L78
because almost all files included (based on my investigation)

Function reload doesn't work too, so I have to do stop-start only.
It uses next code when I'm trying to reload it
https://github.com/k911/swoole-bundle/blob/develop/src/Server/HttpServer.php#L98

I see next logs in var/log/swoole_dev.log

[2020-04-09 15:38:41 $4532.0] INFO Server is reloading all workers now [2020-04-09 15:38:43 *4551.0] WARNING swWorker_reactor_is_empty (ERRNO 9012): worker exit timeout, forced to terminate [2020-04-09 15:38:43 *4552.1] WARNING swWorker_reactor_is_empty (ERRNO 9012): worker exit timeout, forced to terminate

Steps To Reproduce
I created new empty project with only one controller.

Environment (please complete the following information):

  • OS: Ubuntu
  • PHP Version:
  • Swoole Version: 4.4.17
  • Symfony Version:5.0.7
  • Running in docker: No

Caching GRPC response

I am looking to hook up some some basic GRPC/protobuf caching mechanic.

Any idea/hint where I should start look into?

HRM with Docker

Hey everybody,

thanks for this nice bundle. It works very well for me. But I have one question about the HRM feature in combination with Docker.

I have a Dockerfile with swoole and inotify:

FROM php:7.2-cli-alpine

RUN apk add --no-cache xvfb ttf-freefont fontconfig dbus postgresql-dev autoconf make g++ \
    && docker-php-ext-configure mbstring --enable-mbstring \
    && docker-php-ext-install \
        mbstring \
        pgsql \
        pdo_pgsql \
        bcmath \
    && pecl install swoole inotify redis \
    && docker-php-ext-enable redis \
    && touch /usr/local/etc/php/conf.d/swoole.ini \
    && echo 'extension=swoole.so' > /usr/local/etc/php/conf.d/swoole.ini \
    && touch /usr/local/etc/php/conf.d/inotify.ini \
    && echo 'extension=inotify.so' > /usr/local/etc/php/conf.d/inotify.ini

WORKDIR /var/www

EXPOSE 9501

CMD ["bin/console", "swoole:server:run", "--host=0.0.0.0"]

I use this Dockerfile with an docker-compose file which has a php-swoole configuration:

  php-swoole:
    build:
      context: './docker/php-swoole'
    depends_on: ['postgres', 'redis']
    volumes:
      - './config:/var/www/config'
      - './src:/var/www/src'
      - './public:/var/www/public'
      - './bin:/var/www/bin'
      - './templates:/var/www/templates'
      - './translations:/var/www/translations'
      - './vendor:/var/www/vendor:cached'
      - './var:/var/www/var'
      - './composer.json:/var/www/composer.json'
      - './docker/php-swoole/php.ini:/usr/local/etc/php/php.ini'
    links: ['postgres:database', 'redis:pubsub']
    env_file: ['./.env.docker']
    ports: ['9501:9501']

So all symfony files are linked into the container and all needed extensions for swoole and HRM are installed. The symfony project itself also works fine and as expected. But the HRM doesn't work. I have to restart the container every time I change a file. Did I something wrong? I also tried to change the HRM configuration to inotify. The InotifyHRM class is loaded and initialized.

Thanks a lot.

RE - How to fix error handling?

Describe the bug
Linked to #20
From any symfony controller if an error or exception is thrown, the symfony request response cycle does not terminate and the browser (or any client eg postman) is hanging waiting for the response which never comes back.

Steps To Reproduce
I'm adding a repository with a symfony installation wrapped in a docker container to reproduce you would have 3 endpoint

  • localhost:9501/success ok
  • localhost:9501/error throwing error
  • localhost:9501/exception throwing exception

here the repo:
trySwoole.zip

Expected behavior
Response finishes with 500 code / server error

Environment (please complete the following information):
Dockerised varsion started from https://www.swoole.co.uk/article/docker.html but substituted with php php:7.3-cli as the bundle requires 7.3 and swoole-4.4.7

Logs


Fatal error: Uncaught Swoole\ExitException: swoole exit in /app/project/vendor/symfony/debug/ErrorHandler.php:668
Stack trace:
#0 [internal function]: Symfony\Component\Debug\ErrorHandler::Symfony\Component\Debug\{closure}()
#1 {main}
  thrown in /app/project/vendor/symfony/debug/ErrorHandler.php on line 668

docs: Update README.md

TODO:

  • release 0.8.x
  • change composer dev line to 0.8.x
  • mention about AdvancedStaticFilesServer which is now configurable
  • CONTRIBUTING docs update - php 7.3 and up,
  • mention about soon switching fully to php 7.4
  • update swoole to 4.5.x line
  • clarify that HMR currently works only on bare linux (without docker), and possibly only in process mode (see #187 )
  • alpine 3.12 in docker
  • update k911/swoole-bundle-symfony-demo

Lots of timeout when fetching items from database using doctrine

Describe the bug

I got an api which use doctrine to query the database and return json response. I tested it using wrk and the result is not that good due to lots of timeout.

❯ wrk -c100 -t4 http://127.0.0.1:9501/api/common/properties
Running 10s test @ http://127.0.0.1:9501/api/common/properties
  4 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.27s   562.48ms   1.99s    53.33%
    Req/Sec    15.54     11.15    50.00     72.38%
  389 requests in 10.05s, 124.18MB read
  Socket errors: connect 0, read 0, write 0, timeout 299
Requests/sec:     38.72
Transfer/sec:     12.36MB

Steps To Reproduce
I'm using default swoole.yaml config, APP_ENV=prod and also got pixelfederation/doctrine-resettable-em-bundle installed.

swoole:
    http_server:
        port: 9501
        host: 0.0.0.0
        running_mode: process
        socket_type: tcp
        ssl_enabled: false
        trusted_hosts: localhost,127.0.0.1
        trusted_proxies:
            - '*'
            - 127.0.0.1/8
            - 192.168.2./16

        # enables static file serving
        static: advanced
        # equals to:
        # ---
        # static:
        #     public_dir: '%kernel.project_dir%/public'
        #     strategy: advanced
        #     mime_types: ~
        # ---
        # strategy can be one of: (default) auto, off, advanced, default
        #   - off: turn off feature
        #   - auto: use 'advanced' when debug enabled or not production environment
        #   - advanced: use request handler class \K911\Swoole\Server\RequestHandler\AdvancedStaticFilesServer
        #   - default: use default swoole static serving (faster than advanced, but supports less content types)
        # ---
        # mime types registration by file extension for static files serving in format: 'file extension': 'mime type'
        # this only works when 'static' strategy is set to 'advanced'
        #
        #   mime_types:
        #       '*': 'text/plain' # fallback override
        #       customFileExtension: 'custom-mime/type-name'
        #       sqlite: 'application/x-sqlite3'

        # enables hot module reload using inotify
        hmr: auto
        # hmr can be one of: off, (default) auto, inotify
        #   - off: turn off feature
        #   - auto: use inotify if installed in the system
        #   - inotify: use inotify

        # enables api server on specific port
        # by default it is disabled (can be also enabled using --api flag via cli)
        api: false
        # equals to:
        # ---
        # api:
        #     enabled: true
        #     host: 0.0.0.0
        #     port: 9200

        # additional swoole symfony bundle services
        services:
            # see: \K911\Swoole\Bridge\Symfony\HttpKernel\DebugHttpKernelRequestHandler
            debug_handler: true

            # see: \K911\Swoole\Bridge\Symfony\HttpFoundation\TrustAllProxiesRequestHandler
            trust_all_proxies_handler: true

            # see: \K911\Swoole\Bridge\Symfony\HttpFoundation\CloudFrontRequestFactory
            cloudfront_proto_header_handler: true

            # see: \K911\Swoole\Bridge\Doctrine\ORM\EntityManagerHandler
            entity_manager_handler: true
            
            # see: \K911\Swoole\Bridge\Upscale\Blackfire\WithProfiler
            blackfire_profiler: false


        # swoole http server settings
        # see https://www.swoole.co.uk/docs/modules/swoole-server/configuration
        settings:
            reactor_count: 4
            worker_count: 8
            # when not set, swoole sets these are automatically set based on count of host CPU cores
            task_worker_count: auto # one of: positive number, "auto", or null to disable creation of task worker processes (default: null)

            log_level: auto
            # can be one of: (default) auto, debug, trace, info, notice, warning, error
            #   - auto: when debug set to debug, when not set to notice
            #   - {debug,trace,info,notice,warning,error}: see swoole configuration

            log_file: '%kernel.logs_dir%/swoole_%kernel.environment%.log'
            pid_file: /var/run/swoole_http_server.pid

            buffer_output_size: 2097152
            # in bytes, 2097152b = 2 MiB

            package_max_length: 8388608
            # in bytes, 8388608b = 8 MiB
        
            worker_max_request: 0
            # integer >= 0, indicates the number of requests after which a worker reloads automatically
            # This can be useful to limit memory leaks
            worker_max_request_grace: ~
            # 'grace period' for worker reloading. If not set, default is worker_max_request / 2. Worker reloads
            # after 'worker_max_request + rand(0,worker_max_request_grace)' requests

Expected behavior
I think it suppose to be low timeout as possible? Otherwise it make no difference with apache/nginx serving.

Environment (please complete the following information):

  • OS: Zorin OS 15.3 Core
  • PHP Version: 7.4.16
  • Swoole Version: 4.6.4
  • Symfony Version: 5.2.6
  • Running in docker: No

Logs
If possible/applicable please provide symfony/swoole logs here.

Symfony/Swoole Logs

# PASTE LOG LINES HERE

[2021-04-21 18:13:21 @27495.0]	WARNING	file_put_contents(:110): open(/var/run/swoole_http_server.pid) failed, Error: Permission denied[13]
[2021-04-21 18:13:41 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#76 is closed
[2021-04-21 18:13:41 *27543.7]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#25 is closed
[2021-04-21 18:13:41 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#76 is closed
[2021-04-21 18:13:41 *27543.7]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#25 is closed
[2021-04-21 18:13:41 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#98 is closed
[2021-04-21 18:13:41 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#98 is closed
[2021-04-21 18:13:41 *27540.4]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#38 is closed
[2021-04-21 18:13:41 *27540.4]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#38 is closed
[2021-04-21 18:13:41 *27541.5]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#71 is closed
[2021-04-21 18:13:41 *27541.5]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#71 is closed
[2021-04-21 18:13:41 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#59 is closed
[2021-04-21 18:13:41 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#59 is closed
[2021-04-21 18:13:41 *27542.6]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#88 is closed
[2021-04-21 18:13:41 *27542.6]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#88 is closed
[2021-04-21 18:13:41 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#92 is closed
[2021-04-21 18:13:41 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#92 is closed
[2021-04-21 18:13:41 *27543.7]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#33 is closed
[2021-04-21 18:13:41 *27543.7]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#33 is closed
[2021-04-21 18:13:41 *27539.3]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#21 is closed
[2021-04-21 18:13:41 *27539.3]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#21 is closed
[2021-04-21 18:13:41 *27542.6]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#7 is closed
[2021-04-21 18:13:41 *27542.6]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#7 is closed
[2021-04-21 18:13:41 #27495.2]	WARNING	send_to_connection: connection#142 is closed by client
[2021-04-21 18:13:41 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#91 is closed
[2021-04-21 18:13:41 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#91 is closed
[2021-04-21 18:13:41 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#18 is closed
[2021-04-21 18:13:41 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#18 is closed
[2021-04-21 18:13:41 *27541.5]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#95 is closed
[2021-04-21 18:13:41 *27541.5]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#95 is closed
[2021-04-21 18:13:41 *27540.4]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#46 is closed
[2021-04-21 18:13:41 *27540.4]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#46 is closed
[2021-04-21 18:13:41 *27539.3]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#29 is closed
[2021-04-21 18:13:41 *27539.3]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#29 is closed
[2021-04-21 18:13:41 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#100 is closed
[2021-04-21 18:13:41 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#100 is closed
[2021-04-21 18:13:41 *27543.7]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#41 is closed
[2021-04-21 18:13:41 *27543.7]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#41 is closed
[2021-04-21 18:13:41 *27542.6]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#96 is closed
[2021-04-21 18:13:41 *27542.6]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#96 is closed
[2021-04-21 18:13:41 #27495.2]	WARNING	send_to_connection: connection#150 is closed by client
[2021-04-21 18:13:41 #27495.2]	WARNING	send_to_connection: connection#158 is closed by client
[2021-04-21 18:13:41 #27495.2]	WARNING	send_to_connection: connection#166 is closed by client
[2021-04-21 18:13:41 #27495.2]	WARNING	send_to_connection: connection#174 is closed by client
[2021-04-21 18:13:41 #27495.2]	WARNING	send_to_connection: connection#182 is closed by client
[2021-04-21 18:13:41 #27495.2]	WARNING	send_to_connection: connection#190 is closed by client
[2021-04-21 18:13:41 #27495.2]	WARNING	send_to_connection: connection#198 is closed by client
[2021-04-21 18:13:41 #27495.2]	WARNING	send_to_connection: connection#206 is closed by client
[2021-04-21 18:13:41 *27541.5]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#15 is closed
[2021-04-21 18:13:41 *27541.5]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#15 is closed
[2021-04-21 18:13:41 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#67 is closed
[2021-04-21 18:13:41 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#67 is closed
[2021-04-21 18:13:41 *27539.3]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#37 is closed
[2021-04-21 18:13:41 *27539.3]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#37 is closed
[2021-04-21 18:13:41 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#26 is closed
[2021-04-21 18:13:41 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#26 is closed
[2021-04-21 18:13:41 *27540.4]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#54 is closed
[2021-04-21 18:13:41 *27540.4]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#54 is closed
[2021-04-21 18:13:41 *27543.7]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#49 is closed
[2021-04-21 18:13:41 *27543.7]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#49 is closed
[2021-04-21 18:13:41 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#3 is closed
[2021-04-21 18:13:41 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#3 is closed
[2021-04-21 18:13:41 *27541.5]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#23 is closed
[2021-04-21 18:13:41 *27541.5]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#23 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#75 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#75 is closed
[2021-04-21 18:13:42 *27539.3]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#45 is closed
[2021-04-21 18:13:42 *27539.3]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#45 is closed
[2021-04-21 18:13:42 *27543.7]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#57 is closed
[2021-04-21 18:13:42 *27543.7]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#57 is closed
[2021-04-21 18:13:42 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#34 is closed
[2021-04-21 18:13:42 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#34 is closed
[2021-04-21 18:13:42 *27541.5]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#31 is closed
[2021-04-21 18:13:42 *27541.5]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#31 is closed
[2021-04-21 18:13:42 *27540.4]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#62 is closed
[2021-04-21 18:13:42 *27540.4]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#62 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#99 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#99 is closed
[2021-04-21 18:13:42 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#20 is closed
[2021-04-21 18:13:42 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#20 is closed
[2021-04-21 18:13:42 *27539.3]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#53 is closed
[2021-04-21 18:13:42 *27539.3]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#53 is closed
[2021-04-21 18:13:42 *27543.7]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#8 is closed
[2021-04-21 18:13:42 *27543.7]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#8 is closed
[2021-04-21 18:13:42 *27540.4]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#70 is closed
[2021-04-21 18:13:42 *27540.4]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#70 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#2 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#2 is closed
[2021-04-21 18:13:42 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#42 is closed
[2021-04-21 18:13:42 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#42 is closed
[2021-04-21 18:13:42 *27541.5]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#39 is closed
[2021-04-21 18:13:42 *27541.5]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#39 is closed
[2021-04-21 18:13:42 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#28 is closed
[2021-04-21 18:13:42 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#28 is closed
[2021-04-21 18:13:42 *27543.7]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#89 is closed
[2021-04-21 18:13:42 *27543.7]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#89 is closed
[2021-04-21 18:13:42 *27539.3]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#13 is closed
[2021-04-21 18:13:42 *27539.3]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#13 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#10 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#10 is closed
[2021-04-21 18:13:42 *27540.4]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#78 is closed
[2021-04-21 18:13:42 *27540.4]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#78 is closed
[2021-04-21 18:13:42 *27541.5]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#47 is closed
[2021-04-21 18:13:42 *27541.5]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#47 is closed
[2021-04-21 18:13:42 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#50 is closed
[2021-04-21 18:13:42 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#50 is closed
[2021-04-21 18:13:42 *27543.7]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#65 is closed
[2021-04-21 18:13:42 *27543.7]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#65 is closed
[2021-04-21 18:13:42 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#36 is closed
[2021-04-21 18:13:42 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#36 is closed
[2021-04-21 18:13:42 *27539.3]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#77 is closed
[2021-04-21 18:13:42 *27539.3]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#77 is closed
[2021-04-21 18:13:42 *27541.5]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#55 is closed
[2021-04-21 18:13:42 *27541.5]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#55 is closed
[2021-04-21 18:13:42 *27540.4]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#86 is closed
[2021-04-21 18:13:42 *27540.4]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#86 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#19 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#19 is closed
[2021-04-21 18:13:42 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#9 is closed
[2021-04-21 18:13:42 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#9 is closed
[2021-04-21 18:13:42 *27539.3]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#85 is closed
[2021-04-21 18:13:42 *27539.3]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#85 is closed
[2021-04-21 18:13:42 *27543.7]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#73 is closed
[2021-04-21 18:13:42 *27543.7]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#73 is closed
[2021-04-21 18:13:42 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#44 is closed
[2021-04-21 18:13:42 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#44 is closed
[2021-04-21 18:13:42 *27540.4]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#94 is closed
[2021-04-21 18:13:42 *27540.4]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#94 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#27 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#27 is closed
[2021-04-21 18:13:42 *27541.5]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#6 is closed
[2021-04-21 18:13:42 *27541.5]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#6 is closed
[2021-04-21 18:13:42 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#58 is closed
[2021-04-21 18:13:42 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#58 is closed
[2021-04-21 18:13:42 *27539.3]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#61 is closed
[2021-04-21 18:13:42 *27539.3]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#61 is closed
[2021-04-21 18:13:42 *27543.7]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#81 is closed
[2021-04-21 18:13:42 *27543.7]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#81 is closed
[2021-04-21 18:13:42 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#52 is closed
[2021-04-21 18:13:42 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#52 is closed
[2021-04-21 18:13:42 *27540.4]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#5 is closed
[2021-04-21 18:13:42 *27540.4]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#5 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#35 is closed
[2021-04-21 18:13:42 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#35 is closed
[2021-04-21 18:13:42 *27541.5]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#79 is closed
[2021-04-21 18:13:42 *27541.5]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#79 is closed
[2021-04-21 18:13:42 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#66 is closed
[2021-04-21 18:13:42 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#66 is closed
[2021-04-21 18:13:43 *27540.4]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#14 is closed
[2021-04-21 18:13:43 *27540.4]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#14 is closed
[2021-04-21 18:13:43 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#43 is closed
[2021-04-21 18:13:43 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#43 is closed
[2021-04-21 18:13:43 *27539.3]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#93 is closed
[2021-04-21 18:13:43 *27539.3]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#93 is closed
[2021-04-21 18:13:43 *27543.7]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#97 is closed
[2021-04-21 18:13:43 *27543.7]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#97 is closed
[2021-04-21 18:13:43 *27541.5]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#87 is closed
[2021-04-21 18:13:43 *27541.5]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#87 is closed
[2021-04-21 18:13:43 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#11 is closed
[2021-04-21 18:13:43 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#11 is closed
[2021-04-21 18:13:43 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#74 is closed
[2021-04-21 18:13:43 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#74 is closed
[2021-04-21 18:13:43 *27540.4]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#22 is closed
[2021-04-21 18:13:43 *27540.4]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#22 is closed
[2021-04-21 18:13:43 *27541.5]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#63 is closed
[2021-04-21 18:13:43 *27541.5]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#63 is closed
[2021-04-21 18:13:43 *27543.7]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#17 is closed
[2021-04-21 18:13:43 *27543.7]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#17 is closed
[2021-04-21 18:13:43 *27539.3]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#69 is closed
[2021-04-21 18:13:43 *27539.3]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#69 is closed
[2021-04-21 18:13:43 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#82 is closed
[2021-04-21 18:13:43 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#82 is closed
[2021-04-21 18:13:43 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#51 is closed
[2021-04-21 18:13:43 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#51 is closed
[2021-04-21 18:13:43 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#60 is closed
[2021-04-21 18:13:43 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#60 is closed
[2021-04-21 18:13:43 *27540.4]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#30 is closed
[2021-04-21 18:13:43 *27540.4]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#30 is closed
[2021-04-21 18:13:43 *27537.1]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#83 is closed
[2021-04-21 18:13:43 *27537.1]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#83 is closed
[2021-04-21 18:13:43 *27539.3]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#101 is closed
[2021-04-21 18:13:43 *27539.3]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#101 is closed
[2021-04-21 18:13:43 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#12 is closed
[2021-04-21 18:13:43 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#12 is closed
[2021-04-21 18:13:43 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#68 is closed
[2021-04-21 18:13:43 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#68 is closed
[2021-04-21 18:13:43 *27536.0]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#90 is closed
[2021-04-21 18:13:43 *27536.0]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#90 is closed
[2021-04-21 18:13:43 *27538.2]	NOTICE	finish (ERRNO 1004): send 198 bytes failed, because session#84 is closed
[2021-04-21 18:13:43 *27538.2]	NOTICE	finish (ERRNO 1004): send 334534 bytes failed, because session#84 is closed

http response is unavailable

First of all, thank`s for your work.

I have some app, which is only getting some data from database(MySQL) and returning json response. Also I am using redis caching. I am testing my app performance by bombardier. And under pressure my app started to return 500, and log some warnings, like

http response is unavailable (maybe it has been ended or detached)

./bombardier-linux-amd64 -c 10 -d 25s --fasthttp http://localhost:1013/news
Bombarding http://localhost:1013/news for 25s using 10 connection(s)
[=============================================================================================] 25s
Done!
Statistics Avg Stdev Max
Reqs/sec 69.94 82.57 825.46
Latency 143.69ms 284.65ms 3.21s
HTTP codes:
1xx - 0, 2xx - 1475, 3xx - 0, 4xx - 0, 5xx - 285
others - 0
Throughput: 609.71KB/s

Action code example:

public function __invoke(TagAwareCacheInterface $cache, int $newsCacheTtl): JsonResponse
{
    return $cache->get('news_list', function (ItemInterface $item) use ($newsCacheTtl) {
        $item->expiresAfter($newsCacheTtl);

        $news = $this->repository->findNews();

        $item->tag('news_list');

        return new JsonResponse( $this->serializer->serialize([
            'data' => $news,
            'pagination_info' => [
                'limit' => (int) $requestData['limit'],
                'offset' => (int) $requestData['offset'],
                'count' => $this->repository->getNewsCountByParams($requestData),
            ],
        ], 'json'), JsonResponse::HTTP_OK, [], true);
    });
}

Also I figure out, that under pressure my app started to throw exception

Circular reference detected for service "App\Route\GetNewsAction", path: "App\Route\GetNewsAction -> App\Route\GetNewsAction

which seem weird, because if there was some circular reference, my app wouldn`t even start.
What am I doing wrong?

Swoole config

swoole:
  http_server:
    port: 80
    running_mode: reactor
    hmr: off
    services:
      debug_handler: true
      entity_manager_handler: true

    static:
      public_dir: "%kernel.project_dir%/public"
      strategy: default

    settings:
      reactor_count: 2
      worker_count: 4

      worker_max_request: 1024
  • OS: Linux
  • PHP Version:7.4.12
  • Swoole Version: 4.5.10
  • Symfony Version: 4.4.12
  • Running in docker: Yes

Logs

Symfony/Swoole Logs

15:25:02 WARNING   [php] Warning: Swoole\Http\Response::header(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING   [php] Warning: Swoole\Http\Response::status(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING   [php] Warning: Swoole\Http\Response::end(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING   [php] Warning: Swoole\Http\Response::header(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING   [php] Warning: Swoole\Http\Response::status(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING   [php] Warning: Swoole\Http\Response::end(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING   [php] Warning: Swoole\Http\Response::header(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING   [php] Warning: Swoole\Http\Response::status(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]
15:25:02 WARNING   [php] Warning: Swoole\Http\Response::end(): http response is unavailable (maybe it has been ended or detached) ["exception" => ErrorException { …}] ["environment" => "dev","application_name" => "media-service"]

Support for Symfony/PHP sessions



 [OK] Swoole HTTP Server started on http://localhost:9501


 ----------------- -------------------------
  Configuration     Values
 ----------------- -------------------------
  env               dev
  debug             true
  worker_count      4
  memory_limit      512 MiB
  trusted_hosts     127.0.0.1, localhost
  trusted_proxies   *
  public_dir        /var/www/wapinet/public
 ----------------- -------------------------

22:50:53 CRITICAL  [request] Uncaught PHP Exception RuntimeException: "Failed to start the session because headers have already been sent by "" at line 0." at /var/www/wapinet/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php line 138 ["exception" => RuntimeException { …}] []
22:50:53 CRITICAL  [request] Uncaught PHP Exception RuntimeException: "Failed to start the session because headers have already been sent by "" at line 0." at /var/www/wapinet/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php line 138 ["exception" => RuntimeException { …}] []
22:51:18 CRITICAL  [request] Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("Failed to start the session because headers have already been sent by "" at line 0.")." at /var/www/wapinet/vendor/symfony/web-profiler-bundle/Resources/views/Profiler/layout.html.twig line 107 ["exception" => Twig_Error_Runtime { …}] []

Custom handlers

Hello,

Very nice package.

Is possible rewrite the handlers to my customs handlers?
I need add somethings to request and response, but I don't know how.
Thanks!

Random failures on SymfonySessionSwooleSessionStorageTest

Describe the bug
Test suite sometimes fails on SymfonySessionSwooleSessionStorageTest::testUpdateSession

Steps To Reproduce
Run composer feature-tests

Expected behavior
Should not fail.

Environment:

  • Travis CI / Circle

Additional context
Example job: https://travis-ci.org/k911/swoole-bundle/jobs/622487511?utm_medium=notification&utm_source=github_status

Logs

Travis Logs

136.17s$ composer feature-tests
> phpunit tests/Feature --process-isolation --colors=always
PHPUnit 8.5.0 by Sebastian Bergmann and contributors.
Warning:       Invocation with class name is deprecated
...................................F                              36 / 36 (100%)
Time: 2.26 minutes, Memory: 8.00 MB
There was 1 failure:
1) K911\Swoole\Tests\Feature\SymfonySessionSwooleSessionStorageTest::testUpdateSession
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'9127f58638a04a752762165a3f3bb036c4528e29117d7b4fd70c78fc4e122e3'
+'5b98acb04e88847c43a35883839db0e43dd8a101a55f4121b09b8c475e05ea2'
/home/travis/build/k911/swoole-bundle/tests/Feature/SymfonySessionSwooleSessionStorageTest.php:187
/home/travis/build/k911/swoole-bundle/src/Coroutine/CoroutinePool.php:105
FAILURES!
Tests: 36, Assertions: 306, Failures: 1.
Script phpunit tests/Feature --process-isolation --colors=always handling the feature-tests event returned with error code 1
The command "composer feature-tests" exited with 1.

Introduce rectorphp / rector in CI Pipeline

Is your feature request related to a problem? Please describe.
Introduce rectorphp/rector in CI Pipeline to handle coding standards

Describe the solution you'd like
Step in CI pipeline (CircleCI/CodeClimate), handled for example like run-static-analysis (phpstan)

Describe alternatives you've considered
I thought that PHP-CS-Fixer would handle that, but unfortunately, it can't format variable/method names to be in camelCase

Additional context
See: https://github.com/rectorphp/rector#how-to-apply-coding-standards

when require ODM

Cannot autowire service "K911\Swoole\Bridge\Doctrine\ORM\EntityManagerHandl
!! er": argument "$entityManager" of method "__construct()" has type "Doctrine
!! \ORM\EntityManagerInterface" but this class was not found.

require Doctrine ODM without ORM.

Daemonize mode seem to crash with AWS codedeploy

root@ip-10-4-84-141:/home/ubuntu# tail -f /opt/codedeploy-agent/deployment-root/aa90b113-d0ec-4151-b986-fb5d639b701a/d-C2NQCNMH2/logs/scripts.log 
2020-02-08 14:50:56 [stdout]  worker_count      4                                          
2020-02-08 14:50:56 [stdout]  reactor_count     2                                          
2020-02-08 14:50:56 [stdout]  memory_limit      3 GiB                                      
2020-02-08 14:50:56 [stdout]  trusted_hosts                                                
2020-02-08 14:50:56 [stdout]  trusted_proxies                                              
2020-02-08 14:50:56 [stdout]  public_dir        /var/www/project/public  
2020-02-08 14:50:56 [stdout] ----------------- ------------------------------------------- 
2020-02-08 14:50:56 [stdout]
2020-02-08 14:50:56 [stderr]+ echo 'Application start end.'
2020-02-08 14:50:56 [stdout]Application start end.

Here we have a log that the service php ${INSTALL_DIR}/bin/console swoole:server:start started correctly but than the applicationStart event never end and crash like the server is not fully detach from the session.

Here is the config file.

swoole:
  http_server:
    port: 50051
    host: 0.0.0.0
    running_mode: reactor
    socket_type: tcp
    ssl_enabled: false
#    trusted_hosts: localhost,127.0.0.1
#    trusted_proxies:
#      - '*'
#      - 127.0.0.1/8
#      - 192.168.2./16

    # enables static file serving
    static: advanced
    # equals to:
    # ---
    # static:
    #     public_dir: '%kernel.project_dir%/public'
    #     strategy: advanced
    # ---
    # strategy can be one of: (default) auto, off, advanced, default
    #   - off: turn off feature
    #   - auto: use 'advanced' when debug enabled or not production environment
    #   - advanced: use request handler class \K911\Swoole\Server\RequestHandler\AdvancedStaticFilesServer
    #   - default: use default swoole static serving (faster than advanced, but supports less content types)

    # enables hot module reload using inotify
    hmr: off
    # hmr can be one of: off, (default) auto, inotify
    #   - off: turn off feature
    #   - auto: use inotify if installed in the system
    #   - inotify: use inotify

    # enables api server on specific port
    # by default it is disabled (can be also enabled using --api flag via cli)
    api: true
    # equals to:
    # ---
    # api:
    #     enabled: true
    #     host: 0.0.0.0
    #     port: 9200

    # additional swoole symfony bundle services
    services:
      # see: \K911\Swoole\Bridge\Symfony\HttpKernel\DebugHttpKernelRequestHandler
      debug_handler: false

      # see: \K911\Swoole\Bridge\Symfony\HttpFoundation\TrustAllProxiesRequestHandler
      trust_all_proxies_handler: true

      # see: \K911\Swoole\Bridge\Symfony\HttpFoundation\CloudFrontRequestFactory
      cloudfront_proto_header_handler: true

      # see: \K911\Swoole\Bridge\Doctrine\ORM\EntityManagerHandler
      entity_manager_handler: true

    # swoole http server settings
    # see https://www.swoole.co.uk/docs/modules/swoole-server/configuration
    settings:
      #reactor_count: 10
      #worker_count: 4
      # when not set, swoole sets these are automatically set based on count of host CPU cores
      #task_worker_count: auto # one of: positive number, "auto", or null to disable creation of task worker processes (default: null)

      log_level: notice
      # can be one of: (default) auto, debug, trace, info, notice, warning, error
      #   - auto: when debug set to debug, when not set to notice
      #   - {debug,trace,info,notice,warning,error}: see swoole configuration

      log_file: '%kernel.logs_dir%/swoole_%kernel.environment%.log'
      pid_file: '/var/run/swoole_http_server_%env(resolve:SERVICE_NAME)%.pid'

      buffer_output_size: 2097152
      # in bytes, 2097152b = 2 MiB

      package_max_length: 8388608
      # in bytes, 8388608b = 8 MiB

Any idea could help me resolve this?

The bundle seems (too) dependent to Doctrine ORM

Hello!

Describe the bug
I received this error on my project, which only had a dbal entry in doctrine.yaml (no orm):

Cannot autowire service "K911\Swoole\Bridge\Doctrine\ORM\EntityManagerHandler": argument "$entityManager" of method "__construct()" references interface "Doctrine\ORM\EntityManagerInterface" but no such service exists. Did you create a class that implements this interface?                                                 

After having added orm: ~, the error was gone.

Steps To Reproduce
Start a new project with only DBAL configuration, and no ORM one, then run bin/console

Expected behavior
No error

Environment (please complete the following information):

  • OS: Linux
  • PHP Version: 7.4.7
  • Swoole Version: 4.5.2
  • Symfony Version: 4.3.11
  • Running in docker: No

Attempted to call an undefined method named "boot"

swoole:
    http_server:
        # ...
        services:
            debug_handler: true
            entity_manager_handler: true

debug_handler: true causes Attempted to call an undefined method named "boot" of class "K911\Swoole\Bridge\Symfony\HttpKernel\DebugHttpKernelRequestHandler".

Similarly entity_manager_handler: true causes Attempted to call an undefined method named "boot" of class "K911\Swoole\Bridge\Doctrine\ORM\EntityManagerHandler".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.