swooletw / laravel-swoole

High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
MIT License
4.04k stars 390 forks source link

Xdebug issue #465

Closed anasred closed 3 years ago

anasred commented 3 years ago

Make sure you read Issues Guideline and answer these questions before submitting your issue. Thanks! (Any non-English issues will be closed immediately.)

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole)

anas-mac-pro:help-center-swoole-ms anasahmar$ php -v PHP 7.3.20 (cli) (built: Jul 9 2020 23:50:54) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.20, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.20, Copyright (c) 1999-2018, by Zend Technologies with Xdebug v2.9.0, Copyright (c) 2002-2019, by Derick Rethans

anas-mac-pro:help-center-swoole-ms anasahmar$ php --ri swoole

swoole

Swoole => enabled Author => Swoole Team team@swoole.com Version => 4.6.2 Built => Feb 2 2021 19:38:22 coroutine => enabled with boost asm context kqueue => enabled rwlock => enabled pcre => enabled zlib => 1.2.11 brotli => E16777225/D16777225 async_redis => enabled

Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.enable_library => On => On swoole.enable_preemptive_scheduler => Off => Off swoole.display_errors => On => On swoole.use_shortname => On => On swoole.unixsock_buffer_size => 262144 => 262144


2. Please provide your Laravel/Lumen version.

```Laravel Framework Lumen (8.2.2) (Laravel Components ^8.0)```

3. Which release version of this package are you using?

```4.6.2```

4. What did you do? If possible, provide a recipe for reproducing the error.

1- installed swoole using the pecl as per the wiki
2- installed Lumen using:
```composer create-project --prefer-dist laravel/lumen blog```
3- added this line in app.php
```$app->register(SwooleTW\Http\LumenServiceProvider::class);```

5. What did you expect to see?

I expected to see a server with a url after running this command:
```php artisan swoole:http start```

6. What did you see instead?

Fatal error: Uncaught ErrorException: Swoole\Server::start(): Using Xdebug in coroutines is extremely dangerous, please notice that it may lead to coredump! in /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Server/Manager.php on line 99

Call Stack: 0.0010 1404000 1. {main}() /Users/anasahmar/projects/help-center-swoole-ms/artisan:0 0.0462 7555128 2. App\Console\Kernel->handle() /Users/anasahmar/projects/help-center-swoole-ms/artisan:35 0.0851 12723920 3. Illuminate\Console\Application->run() /Users/anasahmar/projects/help-center-swoole-ms/vendor/laravel/lumen-framework/src/Console/Kernel.php:116 0.0853 12726584 4. Illuminate\Console\Application->run() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/console/Application.php:93 0.0930 12729192 5. Illuminate\Console\Application->doRun() /Users/anasahmar/projects/help-center-swoole-ms/vendor/symfony/console/Application.php:166 0.0940 12743272 6. Illuminate\Console\Application->doRunCommand() /Users/anasahmar/projects/help-center-swoole-ms/vendor/symfony/console/Application.php:290 0.0940 12743272 7. SwooleTW\Http\Commands\HttpServerCommand->run() /Users/anasahmar/projects/help-center-swoole-ms/vendor/symfony/console/Application.php:971 0.0954 12929240 8. SwooleTW\Http\Commands\HttpServerCommand->run() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/console/Command.php:121 0.0956 12930592 9. SwooleTW\Http\Commands\HttpServerCommand->execute() /Users/anasahmar/projects/help-center-swoole-ms/vendor/symfony/console/Command/Command.php:256 0.0956 12930968 10. Laravel\Lumen\Application->call() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/console/Command.php:136 0.0956 12930968 11. Illuminate\Container\BoundMethod::call() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/container/Container.php:610 0.0956 12931664 12. Illuminate\Container\BoundMethod::callBoundMethod() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/container/BoundMethod.php:37 0.0956 12931744 13. Illuminate\Container\Util::unwrapIfClosure() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/container/BoundMethod.php:93 0.0956 12931744 14. Illuminate\Container\BoundMethod::Illuminate\Container{closure:/Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/container/BoundMethod.php:35-37}() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/container/Util.php:40 0.0956 12931744 15. SwooleTW\Http\Commands\HttpServerCommand->handle() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/container/BoundMethod.php:36 0.0959 12935672 16. SwooleTW\Http\Commands\HttpServerCommand->runAction() /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Commands/HttpServerCommand.php:73 0.0959 12935672 17. SwooleTW\Http\Commands\HttpServerCommand->restart() /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Commands/HttpServerCommand.php:89 0.0962 12946256 18. SwooleTW\Http\Commands\HttpServerCommand->start() /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Commands/HttpServerCommand.php:168 0.0997 13100296 19. SwooleTW\Http\Server\Manager->run() /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Commands/HttpServerCommand.php:128 0.0997 13100296 20. Swoole\Http\Server->start() /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Server/Manager.php:99

ErrorException: Swoole\Server::start(): Using Xdebug in coroutines is extremely dangerous, please notice that it may lead to coredump! in /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Server/Manager.php on line 99

Call Stack: 0.0010 1404000 1. {main}() /Users/anasahmar/projects/help-center-swoole-ms/artisan:0 0.0462 7555128 2. App\Console\Kernel->handle() /Users/anasahmar/projects/help-center-swoole-ms/artisan:35 0.0851 12723920 3. Illuminate\Console\Application->run() /Users/anasahmar/projects/help-center-swoole-ms/vendor/laravel/lumen-framework/src/Console/Kernel.php:116 0.0853 12726584 4. Illuminate\Console\Application->run() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/console/Application.php:93 0.0930 12729192 5. Illuminate\Console\Application->doRun() /Users/anasahmar/projects/help-center-swoole-ms/vendor/symfony/console/Application.php:166 0.0940 12743272 6. Illuminate\Console\Application->doRunCommand() /Users/anasahmar/projects/help-center-swoole-ms/vendor/symfony/console/Application.php:290 0.0940 12743272 7. SwooleTW\Http\Commands\HttpServerCommand->run() /Users/anasahmar/projects/help-center-swoole-ms/vendor/symfony/console/Application.php:971 0.0954 12929240 8. SwooleTW\Http\Commands\HttpServerCommand->run() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/console/Command.php:121 0.0956 12930592 9. SwooleTW\Http\Commands\HttpServerCommand->execute() /Users/anasahmar/projects/help-center-swoole-ms/vendor/symfony/console/Command/Command.php:256 0.0956 12930968 10. Laravel\Lumen\Application->call() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/console/Command.php:136 0.0956 12930968 11. Illuminate\Container\BoundMethod::call() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/container/Container.php:610 0.0956 12931664 12. Illuminate\Container\BoundMethod::callBoundMethod() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/container/BoundMethod.php:37 0.0956 12931744 13. Illuminate\Container\Util::unwrapIfClosure() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/container/BoundMethod.php:93 0.0956 12931744 14. Illuminate\Container\BoundMethod::Illuminate\Container{closure:/Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/container/BoundMethod.php:35-37}() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/container/Util.php:40 0.0956 12931744 15. SwooleTW\Http\Commands\HttpServerCommand->handle() /Users/anasahmar/projects/help-center-swoole-ms/vendor/illuminate/container/BoundMethod.php:36 0.0959 12935672 16. SwooleTW\Http\Commands\HttpServerCommand->runAction() /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Commands/HttpServerCommand.php:73 0.0959 12935672 17. SwooleTW\Http\Commands\HttpServerCommand->restart() /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Commands/HttpServerCommand.php:89 0.0962 12946256 18. SwooleTW\Http\Commands\HttpServerCommand->start() /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Commands/HttpServerCommand.php:168 0.0997 13100296 19. SwooleTW\Http\Server\Manager->run() /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Commands/HttpServerCommand.php:128 0.0997 13100296 20. Swoole\Http\Server->start() /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Server/Manager.php:99 1.3769 13102048 21. Laravel\Lumen\Application->Laravel\Lumen\Concerns{closure:/Users/anasahmar/projects/help-center-swoole-ms/vendor/laravel/lumen-framework/src/Concerns/RegistersExceptionHandlers.php:44-48}() /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Server/Manager.php:99

In Manager.php line 99:

Uncaught ErrorException: Swoole\Server::start(): Using Xdebug in coroutines is extremely dangerous,
please notice that it may lead to coredump! in /Users/anasahmar/projects/help-center-swoole-ms/vendo
r/swooletw/laravel-swoole/src/Server/Manager.php:99
Stack trace:

0 [internal function]: Laravel\Lumen\Application->Laravel\Lumen\Concerns{closure}(2, 'Swoole\Serv

er::...', '/Users/anasahma...', 99, Array)

1 /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Server/Manager

.php(99): Swoole\Server->start()

2 /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Commands/HttpS

erverCommand.php(128): SwooleTW\Http\Server\Manager->run()

3 /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Commands/HttpS

erverCommand.php(168): SwooleTW\Http\Commands\HttpServerCommand->start()

4 /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Commands/HttpS

erverCommand.php(89): SwooleTW\Http\Commands\HttpSe

In Manager.php line 99:

Uncaught ErrorException: Swoole\Server::start(): Using Xdebug in coroutines is extremely dangerous,
please notice that it may lead to coredump! in /Users/anasahmar/projects/help-center-swoole-ms/vendo
r/swooletw/laravel-swoole/src/Server/Manager.php:99
Stack trace:

0 [internal function]: Laravel\Lumen\Application->Laravel\Lumen\Concerns{closure}(2, 'Swoole\Serv

er::...', '/Users/anasahma...', 99, Array)

1 /Users/anasahmar/projects/help-center-swoole-ms/vendor/swooletw/laravel-swoole/src/Server/Manager

.php(99): Swoole\Server->start()


This is the output of php artisan swoole:http infos:

+-----------------+------------------------------------------------------------------------------+ | Name | Value | +-----------------+------------------------------------------------------------------------------+ | PHP Version | 7.3.20 | | Swoole Version | 4.6.2 | | Laravel Version | Lumen (8.2.2) (Laravel Components ^8.0) | | Listen IP | 127.0.0.1 | | Listen Port | 1215 | | Server Status | Offline | | Reactor Num | 8 | | Worker Num | 1 | | Task Worker Num | 0 | | Websocket Mode | Off | | Master PID | None | | Manager PID | None | | Log Path | /Users/anasahmar/projects/help-center-swoole-ms/storage/logs/swoole_http.log | +-----------------+------------------------------------------------------------------------------+


After seeing the error I created a config file as per the wiki and call it on bootstrap/app.php  by add this ```$app->configure('swoole_http');``` and modified
1- ```'worker_num' => 1,```
2- ```'ob_output' => false,```

<?php

return [ /* -------------------------------------------------------------------------- HTTP server configurations.
@see https://www.swoole.co.uk/docs/modules/swoole-server/configuration
*/
'server' => [
    'host' => env('SWOOLE_HTTP_HOST', '127.0.0.1'),
    'port' => env('SWOOLE_HTTP_PORT', '1215'),
    'public_path' => base_path('public'),
    // Determine if to use swoole to respond request for static files
    'handle_static_files' => env('SWOOLE_HANDLE_STATIC', true),
    'access_log' => env('SWOOLE_HTTP_ACCESS_LOG', false),
    // You must add --enable-openssl while compiling Swoole
    // Put `SWOOLE_SOCK_TCP | SWOOLE_SSL` if you want to enable SSL
    'socket_type' => SWOOLE_SOCK_TCP,
    'process_type' => SWOOLE_PROCESS,
    'options' => [
        'pid_file' => env('SWOOLE_HTTP_PID_FILE', base_path('storage/logs/swoole_http.pid')),
        'log_file' => env('SWOOLE_HTTP_LOG_FILE', base_path('storage/logs/swoole_http.log')),
        'daemonize' => env('SWOOLE_HTTP_DAEMONIZE', false),
        // Normally this value should be 1~4 times larger according to your cpu cores.
        'reactor_num' => env('SWOOLE_HTTP_REACTOR_NUM', swoole_cpu_num()),
        'worker_num' => 1,//env('SWOOLE_HTTP_WORKER_NUM', swoole_cpu_num()),
        'task_worker_num' => env('SWOOLE_HTTP_TASK_WORKER_NUM', swoole_cpu_num()),
        // The data to receive can't be larger than buffer_output_size.
        'package_max_length' => 20 * 1024 * 1024,
        // The data to send can't be larger than buffer_output_size.
        'buffer_output_size' => 10 * 1024 * 1024,
        // Max buffer size for socket connections
        'socket_buffer_size' => 128 * 1024 * 1024,
        // Worker will restart after processing this number of requests
        'max_request' => 3000,
        // Enable coroutine send
        'send_yield' => false,
        // You must add --enable-openssl while compiling Swoole
        'ssl_cert_file' => null,
        'ssl_key_file' => null,
    ],
],

/*
|--------------------------------------------------------------------------
| Enable to turn on websocket server.
|--------------------------------------------------------------------------
*/
'websocket' => [
    'enabled' => env('SWOOLE_HTTP_WEBSOCKET', false),
],

/*
|--------------------------------------------------------------------------
| Hot reload configuration
|--------------------------------------------------------------------------
*/
'hot_reload' => [
    'enabled' => env('SWOOLE_HOT_RELOAD_ENABLE', false),
    'recursively' => env('SWOOLE_HOT_RELOAD_RECURSIVELY', true),
    'directory' => env('SWOOLE_HOT_RELOAD_DIRECTORY', base_path()),
    'log' => env('SWOOLE_HOT_RELOAD_LOG', true),
    'filter' => env('SWOOLE_HOT_RELOAD_FILTER', '.php'),
],

/*
|--------------------------------------------------------------------------
| Console output will be transferred to response content if enabled.
|--------------------------------------------------------------------------
*/
'ob_output' => false,//env('SWOOLE_OB_OUTPUT', true),

/*
|--------------------------------------------------------------------------
| Pre-resolved instances here will be resolved when sandbox created.
|--------------------------------------------------------------------------
*/
'pre_resolved' => [
    'view', 'files', 'session', 'session.store', 'routes',
    'db', 'db.factory', 'cache', 'cache.store', 'config', 'cookie',
    'encrypter', 'hash', 'router', 'translator', 'url', 'log', 'auth',
],

/*
|--------------------------------------------------------------------------
| Instances here will be cleared on every request.
|--------------------------------------------------------------------------
*/
'instances' => [
    //
],

/*
|--------------------------------------------------------------------------
| Providers here will be registered on every request.
|--------------------------------------------------------------------------
*/
'providers' => [

// Illuminate\Pagination\PaginationServiceProvider::class, ],

/*
|--------------------------------------------------------------------------
| Resetters for sandbox app.
|--------------------------------------------------------------------------
*/
'resetters' => [
    SwooleTW\Http\Server\Resetters\ResetConfig::class,
    SwooleTW\Http\Server\Resetters\ResetSession::class,
    SwooleTW\Http\Server\Resetters\ResetCookie::class,
    SwooleTW\Http\Server\Resetters\ClearInstances::class,
    SwooleTW\Http\Server\Resetters\BindRequest::class,
    SwooleTW\Http\Server\Resetters\RebindKernelContainer::class,
    SwooleTW\Http\Server\Resetters\RebindRouterContainer::class,
    SwooleTW\Http\Server\Resetters\RebindViewContainer::class,
    SwooleTW\Http\Server\Resetters\ResetProviders::class,
],

/*
|--------------------------------------------------------------------------
| Define your swoole tables here.
|
| @see https://www.swoole.co.uk/docs/modules/swoole-table
|--------------------------------------------------------------------------
*/
'tables' => [
    // 'table_name' => [
    //     'size' => 1024,
    //     'columns' => [
    //         ['name' => 'column_name', 'type' => Table::TYPE_STRING, 'size' => 1024],
    //     ]
    // ],
],

];


But the error remains the same

** I also made sure that xdebug extension is disabled and it was disabled:

anas-mac-pro:~ anasahmar$ php -i | grep php.ini Configuration File (php.ini) Path => /usr/local/etc/php/7.3 Loaded Configuration File => /usr/local/etc/php/7.3/php.ini anas-mac-pro:~ anasahmar$ cat /usr/local/etc/php/7.3/php.ini | grep xdebug ; zend_extension="xdebug.so"

Arkanius commented 3 years ago

Hi, xdebug isn't compatible with swoole. Try to use sdebug instead