Coder Social home page Coder Social logo

swooletw / laravel-swoole Goto Github PK

View Code? Open in Web Editor NEW
4.0K 112.0 388.0 785 KB

High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.

License: MIT License

PHP 100.00%
swoole swoole-server swoole-http laravel-swoole lumen websocket socket-io laravel php

laravel-swoole's People

Contributors

albertcht avatar alecpl avatar arkanius avatar damonto avatar edricwilliem avatar fractalzombie avatar geneccx avatar happiness9721 avatar hezachary avatar huang-yi avatar kanarip avatar kauanslr avatar killtw avatar kwdwkiss avatar lagerroos avatar larowka avatar lilianjin avatar m3m0r7 avatar mabdulazim avatar marscoo avatar mxp100 avatar nahid avatar netdown avatar pingcheng avatar prolic avatar ramzeng avatar storyn26383 avatar tiamo avatar toxmc avatar vodnicearv 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  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

laravel-swoole's Issues

Uncaught SyntaxError: Unexpected token .

Please answer these questions before submitting your issue. Thanks!

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

2.2.0

  1. Please provide your Laravel/Lumen version.

5.6 Laravel

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

latest now 2.3.9

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

php artisan swoole:http start

  1. What did you expect to see?

My app running

  1. What did you see instead?

It complains about a javascript file I run with "Uncaught SyntaxError: Unexpected token .". When I run with php artisan serve it works perfect.

how can I compatible dev on no swoole-ext environment ?

sometimes need dev on windows mache which no need install swoole-ext.
but the config file

vendor\swooletw\laravel-swoole\config\swoole_http.php

has code swoole_cpu_num() .so its break all project which has no swoole-ext.

can do some fix to solve this situation?

404 on visiting http://127.0.0.1:1215

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole)
PHP 7.2.6 (cli) (built: May 25 2018 06:16:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.6, Copyright (c) 1999-2018, by Zend Technologies
swoole

swoole support => enabled
Version => 2.2.0
Author => tianfeng.han[email: [email protected]]
coroutine => enabled
kqueue => enabled
rwlock => enabled
async http/websocket client => enabled
pcre => enabled
zlib => 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
  1. Please provide your Laravel/Lumen version.
    Laravel Framework 5.5.40

  2. Which release version of this package are you using?
    v2.3.9

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

  • pecl install swoole
  • php -m | grep swoole
  • install the package
  • update config
'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),
        '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'      => 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 request
            'max_request' => 3000,
            // Enable coroutine send
            'send_yield' => true,
            // You must add --enable-openssl while compiling Swoole
            'ssl_cert_file' => null,
            'ssl_key_file'  => null,
        ],
    ],
  • php artisan swoole:http start
  • go to http://127.0.0.1:1215/
  1. What did you expect to see?
    something else other than 404

  2. What did you see instead?
    404

Notes

Ps
is it possible to get swoole to work with valet ?

不支持 DingoAPi的路由啊

Please answer these questions before submitting your issue. Thanks!

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

  2. Please provide your Laravel/Lumen version.

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

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

  5. What did you expect to see?

  6. What did you see instead?

why every worker make the application , but not share?

    /**
     * Create application.
     */
    protected function createApplication()
    {
        return $this->application = Application::make($this->framework, $this->basePath);
    }

Or, when the worker create application, why not pass the current manger container property. it's makes me confused.

like this.

    /**
     * Create application.
     */
    protected function createApplication()
    {
        return $this->application = Application::make($this->framework, $this->basePath, $this->container);
    }

Changes to database config are not applied after connection purge and reconnect

Please answer these questions before submitting your issue. Thanks!

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole)
    PHP 7.2.5 (cli) (built: Apr 26 2018 12:07:32) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.5, Copyright (c) 1999-2018, by Zend Technologies

swoole

swoole support => enabled
Version => 1.10.5
Author => tianfeng.han[email: [email protected]]
kqueue => enabled
rwlock => enabled
async http/websocket client => enabled
pcre => enabled
zlib => enabled

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

  1. Please provide your Laravel/Lumen version.
    Laravel v5.5.40

  2. Which release version of this package are you using?
    v2.3.8

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

        $db = app('db');
        $db->purge('mysql_database_1');
        $db->purge('mysql_database_2');

        $config->set('database.connections.mysql_database_1.database', 'database_5');
        $config->set('database.connections.mysql_database_2.database', 'database_6');

        $db->reconnect('mysql_database_1');
        $db->reconnect('mysql_database_2');
  1. What did you expect to see?
    my newly configured database to be used.

  2. What did you see instead?
    The old config is still used when recreating the database connection.

When access the new laravel application after installed the package, it throw `Uncaught Error: Call to undefined method App\Http\Kernel::setApplication()`

Those are the error message stack.

❯ php artisan swoole:http start
Starting swoole http server...
Swoole http server started: <http://127.0.0.1:1215>
PHP Fatal error:  Uncaught Error: Call to undefined method App\Http\Kernel::setApplication() in /Users/yjh/Code/laravel56/vendor/swooletw/laravel-swoole/src/Server/Application.php:437
Stack trace:
#0 /Users/yjh/Code/laravel56/vendor/swooletw/laravel-swoole/src/Server/Sandbox.php(67): SwooleTW\Http\Server\Application->__clone()
#1 /Users/yjh/Code/laravel56/vendor/swooletw/laravel-swoole/src/Server/Manager.php(252): SwooleTW\Http\Server\Sandbox->getApplication()
#2 {main}
  thrown in /Users/yjh/Code/laravel56/vendor/swooletw/laravel-swoole/src/Server/Application.php on line 437
PHP Stack trace:
PHP   1. {main}() /Users/yjh/Code/laravel56/artisan:0
PHP   2. App\Console\Kernel->handle() /Users/yjh/Code/laravel56/artisan:37
PHP   3. Illuminate\Console\Application->run() /Users/yjh/Code/laravel56/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:122
PHP   4. Illuminate\Console\Application->run() /Users/yjh/Code/laravel56/vendor/laravel/framework/src/Illuminate/Console/Application.php:89
PHP   5. Illuminate\Console\Application->doRun() /Users/yjh/Code/laravel56/vendor/symfony/console/Application.php:143
PHP   6. Illuminate\Console\Application->doRunCommand() /Users/yjh/Code/laravel56/vendor/symfony/console/Application.php:241
PHP   7. SwooleTW\Http\Commands\HttpServerCommand->run() /Users/yjh/Code/laravel56/vendor/symfony/console/Application.php:865
PHP   8. SwooleTW\Http\Commands\HttpServerCommand->run() /Users/yjh/Code/laravel56/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
PHP   9. SwooleTW\Http\Commands\HttpServerCommand->execute() /Users/yjh/Code/laravel56/vendor/symfony/console/Command/Command.php:252
PHP  10. Illuminate\Foundation\Application->call() /Users/yjh/Code/laravel56/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
PHP  11. Illuminate\Container\BoundMethod::call() /Users/yjh/Code/laravel56/vendor/laravel/framework/src/Illuminate/Container/Container.php:564
PHP  12. Illuminate\Container\BoundMethod::callBoundMethod() /Users/yjh/Code/laravel56/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
PHP  13. Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() /Users/yjh/Code/laravel56/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
PHP  14. call_user_func_array:{/Users/yjh/Code/laravel56/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29}() /Users/yjh/Code/laravel56/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
PHP  15. SwooleTW\Http\Commands\HttpServerCommand->handle() /Users/yjh/Code/laravel56/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
PHP  16. SwooleTW\Http\Commands\HttpServerCommand->runAction() /Users/yjh/Code/laravel56/vendor/swooletw/laravel-swoole/src/Commands/HttpServerCommand.php:55
PHP  17. SwooleTW\Http\Commands\HttpServerCommand->start() /Users/yjh/Code/laravel56/vendor/swooletw/laravel-swoole/src/Commands/HttpServerCommand.php:71
PHP  18. SwooleTW\Http\Server\Manager->run() /Users/yjh/Code/laravel56/vendor/swooletw/laravel-swoole/src/Commands/HttpServerCommand.php:94
PHP  19. Swoole\Http\Server->start() /Users/yjh/Code/laravel56/vendor/swooletw/laravel-swoole/src/Server/Manager.php:99

WSS protocol is required

Please answer these questions before submitting your issue. Thanks!

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

  2. Please provide your Laravel/Lumen version.
    laravel => 5.6.21

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

  4. What did you do? If possible, provide a recipe for reproducing the error.
    I need to implement secure websocket (WSS), as I can see, laravel-swoole facade didn't provide any config options or method to make it happens.
    Currently, I modified the source code on Server/Manager.php line 144

        $this->server = new $server($host, $port, SWOOLE_PROCESS, SWOOLE_SOCK_TCP | SWOOLE_SSL);
  1. What did you expect to see?
    allow to create wss server.

  2. What did you see instead?
    Modified the source code so WSS can be used, this should be fix.

Can't load assets via `php artisan swoole:http start`, but `php artisan serve` works fine.

I put my assets in public directory, and use script tag to require them in resources/views/welcome.blade.php, likes below:

<script src="{{ mix('/js/app.js') }}"></script>

In swoole server i got 404 response, but artisan serve works fine with the same code.

// swoole server
http://127.0.0.1:1215/js/app.js // got 404

// artisan serve
http://127.0.0.1:8000/js/app.js // got 200

Is it possible to use Eloquent ORM(eg. pdo-mysql) with laravel-swoole?

Please answer these questions before submitting your issue. Thanks!

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole)
PHP Version     | 7.2.4 
Swoole Version  | 2.1.3   
  1. Please provide your Laravel/Lumen version.
Laravel Version | 5.6.17
  1. Which release version of this package are you using?
"swooletw/laravel-swoole": "^2.3"
  1. What did you do? If possible, provide a recipe for reproducing the error.
Just question.
Is it possible to use Eloquent ORM(eg. pdo-mysql) with laravel-swoole?
  1. What did you expect to see?

  2. What did you see instead?

我做了一些小改进

在我的项目里面使用了一些第三的插件,有很多不可预知的static导致了一些小状况,我修改成下面这样解决了我的问题。希望主分支也可以考虑加入这个机制,每次进入沙盒的时候自动重新初始化类对象里面的static 变量。
image
image

403 Forbidden

Please answer these questions before submitting your issue. Thanks!

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

php7.2.5

  1. Please provide your Laravel/Lumen version.

5.5

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

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

  3. What did you expect to see?

  4. What did you see instead?

Socket.io routes being registered even when Websockets disabled

Please answer these questions before submitting your issue. Thanks!

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole)
php -v
PHP 7.2.4 (cli) (built: Apr 12 2018 02:49:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.4, Copyright (c) 1999-2018, by Zend Technologies
php --ri swoole

swoole

swoole support => enabled
Version => 1.10.5
Author => tianfeng.han[email: [email protected]]
kqueue => enabled
rwlock => enabled
async http/websocket client => enabled
http2 => enabled
pcre => enabled
zlib => enabled
  1. Please provide your Laravel/Lumen version.
    Laravel 5.6.17

  2. Which release version of this package are you using?
    2.3.8

  3. What did you do? If possible, provide a recipe for reproducing the error.
    Set SWOOLE_HTTP_WEBSOCKET in .env to false.

  4. What did you expect to see?
    /socket.io routes not to be registered

  5. What did you see instead?
    /socket.io routes being registered.

Typo in repository description

Your repository description contains a typo ;)

You have:

High performance HTTP sever based on Swoole. Speed up your Laravel or Lumen applications.

Should be:

High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.

Can we use Facades or not?

Please clarify in the Facades page of the wiki whether or not the basic Facades shipped by Laravel are okay to use or not.

I know that statics that are expected to yield different results in different requests should be avoided when developing under Swoole, because all requests happen under a single CLI call.
What is not clear to me though is whether standard Laravel Facades also count as statics to be avoided, or if they are already written cleverly enough that in such multithreaded event loop contexts they are safe to use.

Reset Event Listeners

In my project, I have event listeners which subscribe to certain events in the application. Because service providers register only once during the application boot the dependencies in Listeners constructors gets injected at boot time. Is there a way to reset the Listeners and reattach it somehow on each request?

class MyEventListener
{
  public function __construct(Request $request)
  {
    //Some code
  }
}

The request injected in above listener is always empty.

I tried to reset the provider in swoole.http.providers but that too did not work.

Thanks

Stdout Debug Logs

Currently, when a request is served there is no stdout logging served unless I am missing any configurations here? It would be nice not to see only incoming requests but also some debug logs such as error_log and var_dump in stdout. This will make the debugging of application a lot easier. It also would be great to add how much time the request took to be processed and how much memory it consumed.

The current code seems to create the HTTP Server via a Manager class which does not have access to the SymfonyCommand to spew out logs. I think the Manager(Http & WebSocket) needs some sort of access to SymfonyCommands to format the messages such as info, warn and error.

Hot Reload

I skimmed through the docs but could not find any thing regarding the Hot Reload. Looks like another library is offerring it out of the box using the inotify php extension. Do you intend to support it if currently not available?

Here it is:
https://github.com/scil/LaravelFly

This is more of a question that's why I am not able to provide the detail here apologies for that.

Class swoole.room does not exist, anything missed?

Please answer these questions before submitting your issue. Thanks!

skip first 3 questions unrelated

  1. What did you do? If possible, provide a recipe for reproducing the error.
use SwooleTW\Http\Websocket\Facades\Room;
dd(Room::getRooms(5));
  1. What did you expect to see?
    rooms of specific fd

  2. What did you see instead?
    error shown, Class swoole.room does not exist
    image

Am I miss some configurations?

"The given data was invalid" - Laravel Passport

NOTE: this issue apparently has to do with using $this->router to dispatch requests during requests with Swoole.

After migrating in Docker from using PHP with Apache to PHP with Swoole, everything seems to work fine when calling endpoints (using same login cookie token). However when logging out and trying to log in again, I constantly get {"message":"The given data was invalid.","errors":{"email":["The email field is required."],"password":["The password field is required."]}.

I have a LoginController controller that asks for an email and password to forward to a Laravel Passport controller to log the user in. Unfortunately despite providing the email and password, I get an error message back saying that I didn't even provide an email or password, so the request is invalid. The request seems to fail here: https://github.com/amcsi/jogging/blob/ff6c6f12727ef1b8d5491532eeed92315dbfd0c2/app/Http/Controllers/LoginController.php#L33
This is strange, because I am providing the email and password, and this works fine without laravel-swoole; if I use the project with Apache, this goes through fine, but I get the error mentioned with Swoole.
Could I be doing something wrong?

The project is here: http://jogging.szeremi.org/

You get the same issue even when attempting to log in with a nonexistent email; it still says that you didn't provide an email which is nonsense, because you did!

  1. PHP 7.2.4 (cli) swoole version 2.2.0
  2. Laravel v5.6.3

Cannot start server

I am getting this error

$ php artisan swoole:http start
Starting swoole http server...
Swoole http server started: http://127.0.0.1:1215

In Manager.php line 459:

Call to undefined function SwooleTW\Http\Server\swoole_set_process_name()

pls help

Uncaught SyntaxError: missing ) after argument list

Possible issue while accessing the /horizon/dashboard horizon.

Commands to run:

  1. php artisan horizon
  2. php artisan queue:work --tries=3 --sleep=3
  3. php artisan swoole:http start

I have successfully accessed /horizon/dashboard using the regular valet dev environment.

Please investigate and thanks for your effort on this project.

how to check aysnc flow is working

Please answer these questions before submitting your issue. Thanks!

| PHP Version     | 7.2.5-1+ubuntu16.04.1+deb.sury.org+1               |
| Swoole Version  | 2.1.3                                              |
| Laravel Version | 5.6.21                                             |
| Server Status   | Offline                                            |
| Listen IP       | 127.0.0.1                                          |
| Listen Port     | 1215                                               |
| Websocket Mode  | Off                                                |
| PID             | None                                               |
| Log Path        | /www/htdocs/laraswool/storage/logs/swoole_http.log |
  • How can i check as call are receiving in async flow.
    as i tested with testing route /hello and trying with echo and read file and echo, so processing was as normal php
    how can i check system to is this working in non-blocking?

Please create doc and sample for that to be used as actual practical way.

-- want to leverage php knowledge, but it seems nodejs is ease of doing, what you say.

you did good work, please create few examples as per practical production point of use, with data and file upload etc.

关于task和协程

Please answer these questions before submitting your issue. Thanks!

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

  2. Please provide your Laravel/Lumen version.
    laravel5.5

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

如何实现TASK,协程异步IO?
看了src,只看到task push的方法,请问下以后会加入task自定义操作嘛?

webscoket not Effective

Please provide your Laravel/Lumen version.

laravel5.6

my question?

when i use this package,i find that i can't connect webscoket,should i configuration nginx same with doc?

关于广播无法发送

HI
您好!
Websocket::broadcast()->to(1)->emit('message', 'for your eyes only');
刚刚测试了
broadcast 配合to(fd)无法发送给个人,
broadcast 配合to(room_name)可以发送到群组,
单独to可以发送
qq 20180503185808
qq 20180503185822

Still getting the last authenticated user for every request. Something wrong with sandbox mode?

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

Swoole 2.1.3 on PHP 7.2.5

  1. Please provide your Laravel/Lumen version.

Laravel 5.6.20

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

Log in to the application via Chrome. Ensure you are logged in. Open up another browser (f.e. Firefox) and visit the application's URL. I am instantly logged in in the Firefox session.

  1. What did you expect to see?

Not being logged in in the Firefox session.

  1. What did you see instead?

Logged in in the Firefox session with the user I logged in with in the Chrome session.


I have enabled sandbox mode and running laravel-swoole behind nginx. For some reason, auth isn't reset after each request. Any ideas?

Can't not find namespace?

Well i install this package successfull & i also have install swoole, but when i run php artisan swoole:http start it didn't work:
a
b
May be give me some help?

predis dependency

not everyone is using that client, so it might be a good idea to rely instead on whatever client the project is using phpredis or predis.

there is also redis-async by swoole, maybe the package could rely on it instead if it proves to be better ?

errors with vuejs

Please answer these questions before submitting your issue. Thanks!

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole)
PHP 7.2.6 (cli) (built: May 25 2018 06:16:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.6, Copyright (c) 1999-2018, by Zend Technologies
swoole

swoole support => enabled
Version => 2.2.0
Author => tianfeng.han[email: [email protected]]
coroutine => enabled
kqueue => enabled
rwlock => enabled
async http/websocket client => enabled
pcre => enabled
zlib => 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
  1. Please provide your Laravel/Lumen version.
    Laravel Framework 5.6.24

  2. Which release version of this package are you using?
    v2.3.9

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

  • current config
<?php

use Swoole\Table;

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),
        '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'      => 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 request
            'max_request' => 3000,
            // Enable coroutine send
            'send_yield' => true,
            // 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),
    ],

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

    /*
    |--------------------------------------------------------------------------
    | Instances here will be cleared on every request.
    |--------------------------------------------------------------------------
    */
    'instances' => [
        'auth', 'session', 'routes', 'cache', 'cookies', 'log',
    ],

    /*
    |--------------------------------------------------------------------------
    | Providers here will be registered on every request.
    |--------------------------------------------------------------------------
    */
    'providers' => [
        Illuminate\Pagination\PaginationServiceProvider::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],
        //     ]
        // ],
    ],
];

am using vuejs with laravel, and for some reason i keep getting some weird errors

  1. What did you expect to see?
    it should work without issues same as normal serve

  2. What did you see instead?
    screen shot 2018-06-08 at 6 47 34 am

am not sure if this is an issue on my end alone or is there some conflict between swoole & vuejs

not work with nginx

Please answer these questions before submitting your issue. Thanks!

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

  2. Please provide your Laravel/Lumen version.
    Laravel: 5.4

  3. 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.
    http {
    server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    autoindex off;
    root /var/www/track/public;
    index index.html index.htm index.php;

     location / {
         proxy_http_version 1.1;
         proxy_set_header Connection "keep-alive";
         proxy_set_header X-Real-IP $remote_addr;
         if (!-e $request_filename) {
             proxy_pass http://192.168.10.2:1215;
         }
     }
    

    }
    }

  5. What did you expect to see?
    if use nginx, then output /app/public/index.php 's content. swoole server is working, and exec curl http://127.0.0.1:1215 can get right output.

  6. What did you see instead?

Upload file failed

When I Use Nginx Proxy, Image upload didn't work, Where can the problem occur?

Uncaught Error: Call to undefined method Symfony\Component\HttpFoundation\Cookie::isRaw()

other issue in laravel 5.2

[Symfony\Component\Debug\Exception\FatalErrorException] Uncaught Error: Call to undefined method Symfony\Component\HttpFoundation\Cookie::isRaw() in /var/www/html/dares/vendor/swooletw/laravel-swoole/src/Server/Response.php:89 Stack trace: #0 /var/www/html/dares/vendor/swooletw/laravel-swoole/src/Server/Response.php(54): SwooleTW\Http\Server\Response->sendHeaders() #1 /var/www/html/dares/vendor/swooletw/laravel-swoole/src/Server/Manager.php(269): SwooleTW\Http\Server\Response->send() #2 {main} thrown

Error "Sandbox is not enabled yet"

Please answer these questions before submitting your issue. Thanks!

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

PHP 7.2.3-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Mar 6 2018 11:18:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.3-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

swoole

swoole support => enabled
Version => 2.2.0
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

  1. Please provide your Laravel/Lumen version.

Laravel Framework 5.6.20

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

Latest 2.3.9

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

php artisan swoole:http start

  1. What did you expect to see?

Application

  1. What did you see instead?

Alert!: HTTP/1.1 500 Internal Server Error

SwooleTW \ Http \ Exceptions \ SandboxException
Sandbox is not enabled yet.
*
*
*

SwooleTW\Http\Exceptions\SandboxException thrown with message "Sandbox is not enabled yet." Stacktrace: #3 SwooleTW\Http\Exceptions\SandboxException in
/home/forge/backpack.cafepro.gr/vendor/swooletw/laravel-swoole/src/Server/Sandbox.php:120 #2 SwooleTW\Http\Server\Sandbox:getApplication in
/home/forge/backpack.cafepro.gr/vendor/swooletw/laravel-swoole/src/Server/Sandbox.php:290 #1 SwooleTW\Http\Server\Sandbox:getLaravelApp in
/home/forge/backpack.cafepro.gr/vendor/swooletw/laravel-swoole/src/Server/Sandbox.php:298 #0 SwooleTW\Http\Server\Sandbox:enable in
/home/forge/backpack.cafepro.gr/vendor/swooletw/laravel-swoole/src/Server/Manager.php:258 (BUTTON) COPY

Benchmarking

Good job. It's great. I wanna check it out as soon.

By the way... do you have any other benchmarking report?

Because I care about memory leaks as PHP-PM also has.

What's the memory leak rate? Does it have any?

静态变量的问题

如果有静态闭包很危险,这个地方的写法一直引用之前初始化好的 app对象,导致后面的新的请求调用都会出问题。从项目考虑,如果一些第三方包使用这种方式,肯定有隐含的问题,如果能及时报错提醒出来就能保障使用者及时发现哪里有变量污染。不知道能否解决 app这个对象用完就初始化为null,保障下次请求这种闭包的调用及时报错,不会出现使用错误的数据。

image

WebSocket events not firing.

Please answer these questions before submitting your issue. Thanks!

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

PHP

PHP 7.2.6 (cli) (built: May 25 2018 06:18:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.6, Copyright (c) 1999-2018, by Zend Technologies

Swoole

swoole

swoole support => enabled
Version => 2.2.0
Author => tianfeng.han[email: [email protected]]
coroutine => enabled
kqueue => enabled
rwlock => enabled
async http/websocket client => enabled
sockets => enabled
pcre => enabled
zlib => 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
  1. Please provide your Laravel/Lumen version.
Lumen (5.5.2) (Laravel Components 5.5.*)
  1. Which release version of this package are you using?
"swooletw/laravel-swoole": "^2.3",
  1. What did you do? If possible, provide a recipe for reproducing the error.

I created a websocket server using swooletw/laravel-swoole and connected it with Socket.io client.
Everythings looks fine. The WebSocket was connected. however, On the socket server the Connect and Open events not firing. Only disconnect event is working.

Here is my websocket.php routes.

<?php

use Illuminate\Http\Request;
use SwooleTW\Http\Websocket\Facades\Websocket;

/*
|--------------------------------------------------------------------------
| Websocket Routes
|--------------------------------------------------------------------------
|
| Here is where you can register websocket events for your application.
|
*/
Websocket::on('open', function ($websocket, $request) {
    Log::info('Opened' . $websocket->getSender());
});

Websocket::on('connect', function ($websocket, $request) {
    Log::info('Connected' . $websocket->getSender());
    // called while socket on connect.
});

Websocket::on('disconnect', function ($websocket) {
    Log::info('Disconnected' . $websocket->getSender());
    // called while socket on disconnect
});

And here is my frontend code.

<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js"></script>
    <script type="text/javascript">
        const socket = io.connect('http://127.0.0.1:1215')

        socket.on('connect', () => console.log(socket.id))
        socket.on('disconnect', reason => console.log(reason))

        setTimeout(() => {
            socket.emit('messages')
        }, 100)
        socket.on('messages', m => {
            document.querySelector('#messages').innerText = m
            // console.log(JSON.parse(base64Decode(m)))
        })

        const base64Decode = (str) => {
            return decodeURIComponent(atob(str).split('').map(function(c) {
                return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
            }).join(''))
        }

Here is my logs.

[2018-06-08 03:50:19] lumen.INFO: Disconnected2  
[2018-06-08 03:50:21] lumen.INFO: Disconnected5  
[2018-06-08 03:50:21] lumen.INFO: Disconnected7  
[2018-06-08 03:50:21] lumen.INFO: Disconnected8  
[2018-06-08 03:50:21] lumen.INFO: Disconnected9  

I'm sorry for my poor English.

app()->runningInConsole() true on HTTP request

Please answer these questions before submitting your issue. Thanks!

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole)
    PHP 7.2.5 (cli) (built: Apr 26 2018 12:07:32) ( NTS )
    Copyright (c) 1997-2018 The PHP Group
    Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.5, Copyright (c) 1999-2018, by Zend Technologies

swoole

swoole support => enabled
Version => 1.10.5
Author => tianfeng.han[email: [email protected]]
kqueue => enabled
rwlock => enabled
async http/websocket client => enabled
pcre => enabled
zlib => enabled

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

  1. Please provide your Laravel/Lumen version.
    Laravel v5.5.40

  2. Which release version of this package are you using?
    v2.3.8

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

app()->runningInConsole()
  1. What did you expect to see?
    false

  2. What did you see instead?
    true

Somehow, php thinks it's running from a cli program as php_sapi_name() returns cli when executed during a http request. This is in essence true as the server is started from a cli command. But can't we somehow tell PHP that we're not running in cli, but from swoole or something else?

StreamedResponse not working

Please answer these questions before submitting your issue. Thanks!

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole)
    PHP 7.2.0-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Nov 30 2017 13:58:33) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.2.0-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
    with blackfire v1.18.0~linux-x64-non_zts72, https://blackfire.io, by SensioLabs

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
2. Please provide your Laravel/Lumen version.
Laravel 5.6.21

  1. Which release version of this package are you using?
    2.3.4

  2. 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();
  1. What did you expect to see?
    The string "test" being echoed. (code works with nginx/php-fpm)

  2. What did you see instead?
    0 bytes are returned and server returns a 500.

Controller method as callback not working in websocket route file

Please answer these questions before submitting your issue. Thanks!

Please provide your PHP and Swoole version. (php -v and php --ri swoole)
php => 7.1.17
swoole => 2.1.3

Please provide your Laravel/Lumen version.
laravel => 5.6.21

Which release version of this package are you using?
version 2.3.6

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

  1. create a controller name WebSocketController by using artisan command
php artisan make:controller WebSocketController
  1. create a new function in this controller
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;

class WebSocketController
{
    public function connect($websocket, $request)
    {      
        $websocket->emit('message', "welcome to connect");
    }
}
  1. modify connect event callback from closure function to string in route/websocket.php
Websocket::on('connect', 'WebSocketController@connect');
  1. run swoole command reload the code logic
php artisan swoole:http reload
  1. connect to websocket on client side successfully.

What did you see instead?
No message received. (should show "welcome to connect")

Uncaught Error: Call to undefined method Symfony\Component\HttpFoundation\ResponseHeaderBag::allPreserveCaseWithoutCookies()

i get this error when i try to access the website

[Symfony\Component\Debug\Exception\FatalErrorException] Uncaught Error: Call to undefined method Symfony\Component\HttpFoundation\ResponseHeaderBag::allPreserveCaseWithoutCookies() in /var/www/html/dares/vendor/swooletw/laravel-s woole/src/Server/Response.php:73 Stack trace: #0 /var/www/html/dares/vendor/swooletw/laravel-swoole/src/Server/Response.php(54): SwooleTW\Http\Server\Response->sendHeaders() #1 /var/www/html/dares/vendor/swooletw/laravel-swoole/src/Server/Manager.php(189): SwooleTW\Http\Server\Response->send() #2 {main} thrown

Working example of NGINX config?

I have used this configuration with my nginx server

#79

But it looks like it doesn't work. It downloads the index file (php) as plain text.
Can anyone share a working example?

Thanks

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.