swooletw / laravel-swoole Goto Github PK
View Code? Open in Web Editor NEWHigh performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
License: MIT License
High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
License: MIT License
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.
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
Please answer these questions before submitting your issue. Thanks!
Please provide your PHP and Swoole version. (php -v
and php --ri swoole
)
Please provide your Laravel/Lumen version.
Which release version of this package are you using?
What did you do? If possible, provide a recipe for reproducing the error.
What did you expect to see?
What did you see instead?
Thank you for this great package!
I am running Swoole 2.1.3 on PHP 7.2.5 with Laravel 5.6.20 and seeing a Uncaught Error: Call to a member function fire() on null in vendor/swooletw/laravel-swoole/src/Server/Manager.php:336 in my Laravel logs. Has something to do with events, any idea?
Get yourselves some beers with your first donation(s).
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 |
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.
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.
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);
What did you expect to see?
allow to create wss server.
What did you see instead?
Modified the source code so WSS can be used, this should be fix.
Please answer these questions before submitting your issue. Thanks!
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
Please provide your Laravel/Lumen version.
Laravel 5.6.17
Which release version of this package are you using?
2.3.8
What did you do? If possible, provide a recipe for reproducing the error.
Set SWOOLE_HTTP_WEBSOCKET in .env
to false
.
What did you expect to see?
/socket.io
routes not to be registered
What did you see instead?
/socket.io
routes being registered.
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!
Please answer these questions before submitting your issue. Thanks!
php -v
and php --ri swoole
)PHP Version | 7.2.4
Swoole Version | 2.1.3
Laravel Version | 5.6.17
"swooletw/laravel-swoole": "^2.3"
Just question.
Is it possible to use Eloquent ORM(eg. pdo-mysql) with laravel-swoole?
What did you expect to see?
What did you see instead?
I Am Using laravel 5.4 when i run php artisan swoole:http start
i get this error Call to undefined function SwooleTW\Http\Server\swoole_set_process_name()
Please answer these questions before submitting your issue. Thanks!
skip first 3 questions unrelated
use SwooleTW\Http\Websocket\Facades\Room;
dd(Room::getRooms(5));
What did you expect to see?
rooms of specific fd
What did you see instead?
error shown, Class swoole.room does not exist
Am I miss some configurations?
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?
Please answer these questions before submitting your issue. Thanks!
php -v
and php --ri swoole
)2.2.0
5.6 Laravel
latest now 2.3.9
php artisan swoole:http start
My app running
It complains about a javascript file I run with "Uncaught SyntaxError: Unexpected token .". When I run with php artisan serve it works perfect.
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.
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
Please provide your Laravel/Lumen version.
Laravel Framework 5.5.40
Which release version of this package are you using?
v2.3.9
What did you do? If possible, provide a recipe for reproducing the error.
pecl install swoole
php -m | grep swoole
'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
http://127.0.0.1:1215/
What did you expect to see?
something else other than 404
What did you see instead?
404
php artisan serve
or using valet
works without issues/usr/local/etc/nginx/nginx.conf
with https://github.com/swooletw/laravel-swoole/wiki/9.-Nginx-Configuration made no differencePs
is it possible to get swoole to work withvalet
?
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
Please answer these questions before submitting your issue. Thanks!
php -v
and php --ri swoole
)php7.2.5
5.5
Which release version of this package are you using?
What did you do? If possible, provide a recipe for reproducing the error.
What did you expect to see?
What did you see instead?
Please answer these questions before submitting your issue. Thanks!
php -v
and php --ri swoole
)swoole
swoole support => enabled
Version => 2.1.3
Author => tianfeng.han[email: [email protected]]
coroutine => enabled
epoll => enabled
eventfd => enabled
timerfd => enabled
signalfd => enabled
cpu affinity => enabled
spinlock => enabled
rwlock => enabled
async http/websocket client => enabled
Linux Native AIO => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
2. Please provide your Laravel/Lumen version.
Laravel 5.6.21
Which release version of this package are you using?
2.3.4
What did you do? If possible, provide a recipe for reproducing the error.
SomeController@show
$response = new \Symfony\Component\HttpFoundation\StreamedResponse(function() {
echo 'test';
}, 200, []);
return $response->send();
What did you expect to see?
The string "test" being echoed. (code works with nginx/php-fpm)
What did you see instead?
0 bytes are returned and server returns a 500.
laravel5.6
when i use this package,i find that i can't connect webscoket,should i configuration nginx same with doc?
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
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
一直无法调用onMessage 看了源码才知道有个eventExists的判断
请问下event在哪配置?
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
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?
Please answer these questions before submitting your issue. Thanks!
php -v
and 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
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
Please provide your Laravel/Lumen version.
Laravel v5.5.40
Which release version of this package are you using?
v2.3.8
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');
What did you expect to see?
my newly configured database to be used.
What did you see instead?
The old config is still used when recreating the database connection.
Please answer these questions before submitting your issue. Thanks!
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
Please provide your Laravel/Lumen version.
Laravel Framework 5.6.24
Which release version of this package are you using?
v2.3.9
What did you do? If possible, provide a recipe for reproducing the error.
<?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
What did you expect to see?
it should work without issues same as normal serve
am not sure if this is an issue on my end alone or is there some conflict between swoole & vuejs
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.
Possible issue while accessing the /horizon/dashboard
horizon.
Commands to run:
php artisan horizon
php artisan queue:work --tries=3 --sleep=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.
试添加ROOM,这些数据是存在内存里的嘛? restart/stop room存的数据会清空?建议持久化数据 - -
php -v
and php --ri swoole
)Swoole 2.1.3 on PHP 7.2.5
Laravel 5.6.20
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.
Not being logged in in the Firefox session.
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?
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.
php artisan make:controller WebSocketController
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
class WebSocketController
{
public function connect($websocket, $request)
{
$websocket->emit('message', "welcome to connect");
}
}
Websocket::on('connect', 'WebSocketController@connect');
php artisan swoole:http reload
What did you see instead?
No message received. (should show "welcome to connect")
I have used this configuration with my nginx server
But it looks like it doesn't work. It downloads the index file (php) as plain text.
Can anyone share a working example?
Thanks
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
Please answer these questions before submitting your issue. Thanks!
Please provide your PHP and Swoole version. (php -v
and php --ri swoole
)
php 7.2
swoole2.1.3
Please provide your Laravel/Lumen version.
laravel5.5
Which release version of this package are you using?
2.2.1
如何实现TASK,协程异步IO?
看了src,只看到task push的方法,请问下以后会加入task自定义操作嘛?
PHP v 7.1.9
Laravel: 5.6
PHP Debugbar is a useful tool that helps you understand the memoray usage and debug queries etc. It looks like the Laravel extension for it is not working with Laravel-Swoole:
https://github.com/barryvdh/laravel-debugbar
Do I need to configure something to make it work?
/**
* 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);
}
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.6
swoole: 2.2.0
Please provide your Laravel/Lumen version.
Laravel: 5.4
Which release version of this package are you using?
2.3
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;
}
}
}
}
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.
What did you see instead?
i just started using swoole in laravel 5.6 but paginate is not working
plz check
Please answer these questions before submitting your issue. Thanks!
php -v
and 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
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
Please provide your Laravel/Lumen version.
Laravel v5.5.40
Which release version of this package are you using?
v2.3.8
What did you do? If possible, provide a recipe for reproducing the error.
app()->runningInConsole()
What did you expect to see?
false
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?
Please answer these questions before submitting your issue. Thanks!
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
Laravel Framework 5.6.20
Latest 2.3.9
php artisan swoole:http start
Application
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
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.
When I Use Nginx Proxy, Image upload didn't work, Where can the problem occur?
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 ?
Please answer these questions before submitting your issue. Thanks!
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
Lumen (5.5.2) (Laravel Components 5.5.*)
"swooletw/laravel-swoole": "^2.3",
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.