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
2. Please provide your Laravel/Lumen version.
Laravel Framework 5.6.24
3. Which release version of this package are you using?
v2.3.9
4. What did you do? If possible, provide a recipe for reproducing the error.
- current config
```php
<?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
What did you see instead?

am not sure if this is an issue on my end alone or is there some conflict between swoole & vuejs
@ctf0 Hi, ctf0, it's looks like you got a syntax error in your vuejs project, it's doesn't matter about the Laravel or laravel-swoole project
actually believe it or not every time i refresh the error changes, its not related to vue cuz using valet or artisan serve works correctly, this errors show only with swoole.
honestly this is not really an issue, i just though maybe some one have encountered a similar problem like this b4 and can help with a way around it
You should serve your static files through nginx. Looks like Swoole does not play well with serving static files look here https://github.com/swoole/swoole-src/issues/1687
and Nginx config:
server {
listen 80;
listen [::]:80;
server_name site.local;
root /srv/site/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location @laravel {
rewrite / /index.laravel.php?$query_string;
}
location @swoole {
# We should not rely on time and below lines shall be removed in production
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://swoole:8080;
}
location ~* \.(css|js|jpg|jpeg|png)$ {
root /srv/site/public;
}
location ~ /\.ht {
deny all;
}
}
If swoole is running on your localhost then change proxy_pass to http://localhost:8080
@aftabnaveed am on mac, adding the above to nginx.conf returns
nginx: [emerg] "server" directive is not allowed here in /usr/local/etc/nginx/nginx.conf:8
am not sure where the logic should be added 馃槩
PS
do u know a way to use swoole with valet ?
Hi @ctf0 , @Abbotton ,
I believe this is caused by sendfile function in Swoole. (see: #30 ) It seems only happens on specific js files, but not sure it's related to vue or webpack yet. Using Nginx for handing static files is what I could suggest for this issue now.
Hi @ctf0 ,
Try to create an independent config file in sites-enabled folder.
@albertcht got it ,i'll check out this, thx
@albertcht added include sites-enabled/*.conf; to nginx & swoole.conf with the config from @aftabnaveed , still the same nothing changed 馃槥
Hi @ctf0 ,
Please refer to https://www.linode.com/docs/web-servers/nginx/how-to-configure-nginx/ for configuration.
Use nginx -t to check if you have syntax errors in your configs.
@albertcht what bugs me is that i've already tried like 5 different configs for swoole and all return the same results.
i understand that most of them are for linux systems where u have one path to serve the files, but on localhost its a different story.
anyway i will try again with the docs link, appreciated :+1:
i gave up, nothing changed
@albertcht u can close the ticket if u want
@aftabnaveed nginx example doesnt work for me, it downloads the index.php file as text when I run my site. Any idea?
Hi @ctf0 ,
I think you're just stuck with how to configure your nginx. You can open another issue if there's any issue related this package.