simple-swoole / simps Goto Github PK
View Code? Open in Web Editor NEW🚀 A simple, lightweight and high-performance PHP coroutine framework.
Home Page: https://simps.io
License: Apache License 2.0
🚀 A simple, lightweight and high-performance PHP coroutine framework.
Home Page: https://simps.io
License: Apache License 2.0
can i connect websockets server?
Ah!, my mystake, i put issue like a party, but, first is for congratulations you, is a god job, i think move to rust in two years, but with this approach i can wait more time.
Have plans for ht2 protocol ? this product have a roadmap ? What is way to contribute ?
Sorry for much question, thanks for attention.
ws服务启动的时候 没有像http一样增加sock_type的定义
$this->_server = new Server($wsConfig['ip'], $wsConfig['port'], $config['mode']);
默认应该是SWOOLE_SOCK_TCP这个不支持ipv6
在配置里的sock_type 在这里没有加入执行.
我看了文档,说 Medoo 应该继承于 BaseModel,这样的话,我遇到的问题是,实例化他们的参数不一样,是不是还要做另外的封装
Would you please add more information about servers.php, like complete Http example be with the parameters description.
composer install ErrorException
Can I translate the documentation to Portuguese and submit a PR?
❯ composer create-project simple-swoole/skeleton todo-simps
Creating a "simple-swoole/skeleton" project at "./todo-simps"
Info from https://repo.packagist.org: #StandWithUkraine
In CreateProjectCommand.php line 435:
Could not find package simple-swoole/skeleton with stability stable in a version installable using your PHP version, PHP extensions and Composer version.
$request, $response建议成一个组件,不用默认传递这2个参数吧
代码不会实施更新,需要重启服务才行?
多个数据库怎么创建连接,谢谢
我搭建了一个mqtt服务,显示mqtt运行。 创建了mqttserver, 粘贴服务端代码。 但是无法连接使用。
mqtt为什么订阅主题后收不到发布的消息
似乎没有提供这个功能,要实现这个功能,在不修改源码的情况下,要怎么实现呢
How to connect to multiple databases?
config/database.php only the pool to one database is calculated.
我看了文档,说 Medoo 应该继承于 BaseModel,这样的话,我遇到的问题是,实例化他们的参数不一样,是不是还要做另外的封装
swoole 版本4.4.12
PHP Version => 7.2.11
运行命令:php bin/simps.php http:start
刚订阅时能正常收到消息,运行几十分钟后就收不到消息了:
https://simps.io/#/zh-cn/mqtt/client?id=%e8%ae%a2%e9%98%85
报错日志
string(19) "onWorkerStart error"
array(4) {
["type"]=>
int(1)
["message"]=>
string(936) "Uncaught PDOException: Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in @swoole-src/library/core/Database/PDOProxy.php:64
Stack trace:
#0 /alidata/www/tournament/vendor/simple-swoole/db/src/BaseModel.php(1352): Swoole\Database\PDOProxy->__call()
#1 /alidata/www/tournament/vendor/simple-swoole/db/src/BaseModel.php(131): Simps\DB\BaseModel->realGetConn()
#2 /alidata/www/tournament/vendor/simple-swoole/db/src/BaseModel.php(491): Simps\DB\BaseModel->exec()
#3 /alidata/www/tournament/app/Gateway.php(104): Simps\DB\BaseModel->get()
#4 /alidata/www/tournament/app/Server.php(480): Game\App\Gateway::getPlayerData()
#5 /alidata/www/tournament/app/Server.php(319): Game\App\Server->joinGameRoom()
#6 {main}
thrown"
["file"]=>
string(46) "@swoole-src/library/core/Database/PDOProxy.php"
["line"]=>
int(64)
}
errCode: 0, errMsg: Success
string(15) "debug_backtrace"
array(1) {
[0]=>
array(5) {
["function"]=>
string(18) "Game\App\{closure}"
["class"]=>
string(15) "Game\App\Server"
["object"]=>
object(Game\App\Server)#3 (1) {
["server":"Game\Core\BaseServer":private]=>
object(Swoole\WebSocket\Server)#2 (26) {
["onStart":"Swoole\Server":private]=>
array(2) {
[0]=>
*RECURSION*
[1]=>
string(7) "onStart"
}
["onShutdown":"Swoole\Server":private]=>
NULL
["onWorkerStart":"Swoole\Server":private]=>
array(2) {
[0]=>
*RECURSION*
[1]=>
string(13) "onWorkerStart"
}
["onWorkerStop":"Swoole\Server":private]=>
array(2) {
[0]=>
*RECURSION*
[1]=>
string(12) "onWorkerStop"
}
["onBeforeReload":"Swoole\Server":private]=>
NULL
["onAfterReload":"Swoole\Server":private]=>
NULL
["onWorkerExit":"Swoole\Server":private]=>
array(2) {
[0]=>
*RECURSION*
[1]=>
string(12) "onWorkerExit"
}
["onWorkerError":"Swoole\Server":private]=>
array(2) {
[0]=>
*RECURSION*
[1]=>
string(13) "onWorkerError"
}
["onTask":"Swoole\Server":private]=>
array(2) {
[0]=>
*RECURSION*
[1]=>
string(6) "onTask"
}
["onFinish":"Swoole\Server":private]=>
array(2) {
[0]=>
*RECURSION*
[1]=>
string(8) "onFinish"
}
["onManagerStart":"Swoole\Server":private]=>
array(2) {
[0]=>
*RECURSION*
[1]=>
string(14) "onManagerStart"
}
["onManagerStop":"Swoole\Server":private]=>
NULL
["onPipeMessage":"Swoole\Server":private]=>
NULL
["setting"]=>
array(16) {
["max_request"]=>
int(0)
["worker_num"]=>
int(1)
["task_worker_num"]=>
int(2)
["dispatch_mode"]=>
int(5)
["hook_flags"]=>
int(2147479551)
["enable_coroutine"]=>
bool(true)
["task_enable_coroutine"]=>
bool(true)
["max_wait_time"]=>
int(15)
["reload_async"]=>
bool(true)
["output_buffer_size"]=>
int(4294967295)
["max_connection"]=>
int(1024)
["open_http_protocol"]=>
bool(true)
["open_mqtt_protocol"]=>
bool(false)
["open_eof_check"]=>
bool(false)
["open_length_check"]=>
bool(false)
["open_websocket_protocol"]=>
bool(true)
}
["connections"]=>
object(Swoole\Connection\Iterator)#6 (0) {
}
["host"]=>
string(7) "0.0.0.0"
["port"]=>
int(9502)
["type"]=>
int(1)
["mode"]=>
int(2)
["ports"]=>
array(1) {
[0]=>
object(Swoole\Server\Port)#4 (16) {
["onConnect":"Swoole\Server\Port":private]=>
NULL
["onReceive":"Swoole\Server\Port":private]=>
NULL
["onClose":"Swoole\Server\Port":private]=>
array(2) {
[0]=>
*RECURSION*
[1]=>
string(7) "onClose"
}
["onPacket":"Swoole\Server\Port":private]=>
NULL
["onBufferFull":"Swoole\Server\Port":private]=>
NULL
["onBufferEmpty":"Swoole\Server\Port":private]=>
NULL
["onRequest":"Swoole\Server\Port":private]=>
NULL
["onHandShake":"Swoole\Server\Port":private]=>
NULL
["onOpen":"Swoole\Server\Port":private]=>
array(2) {
[0]=>
*RECURSION*
[1]=>
string(6) "onOpen"
}
["onMessage":"Swoole\Server\Port":private]=>
array(2) {
[0]=>
*RECURSION*
[1]=>
string(9) "onMessage"
}
["host"]=>
string(7) "0.0.0.0"
["port"]=>
int(9502)
["type"]=>
int(1)
["sock"]=>
int(3)
["setting"]=>
array(9) {
["max_request"]=>
int(0)
["worker_num"]=>
int(1)
["task_worker_num"]=>
int(2)
["dispatch_mode"]=>
int(5)
["hook_flags"]=>
int(2147479551)
["enable_coroutine"]=>
bool(true)
["task_enable_coroutine"]=>
bool(true)
["max_wait_time"]=>
int(15)
["reload_async"]=>
bool(true)
}
["connections"]=>
object(Swoole\Connection\Iterator)#5 (0) {
}
}
}
["master_pid"]=>
int(29448)
["manager_pid"]=>
int(29449)
["worker_id"]=>
int(0)
["taskworker"]=>
bool(false)
["worker_pid"]=>
int(29453)
["stats_timer"]=>
NULL
}
}
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
}
[2021-08-09 19:30:23 *29453.0] ERROR php_swoole_server_rshutdown (ERRNO 503): Fatal error: Uncaught PDOException: Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in @swoole-src/library/core/Database/PDOProxy.php:64
Stack trace:
#0 /alidata/www/tournament/vendor/simple-swoole/db/src/BaseModel.php(1352): Swoole\Database\PDOProxy->__call()
#1 /alidata/www/tournament/vendor/simple-swoole/db/src/BaseModel.php(131): Simps\DB\BaseModel->realGetConn()
#2 /alidata/www/tournament/vendor/simple-swoole/db/src/BaseModel.php(491): Simps\DB\BaseModel->exec()
#3 /alidata/www/tournament/app/Gateway.php(104): Simps\DB\BaseModel->get()
#4 /alidata/www/tournament/app/Server.php(480): Game\App\Gateway::getPlayerData()
#5 /alidata/www/tournament/app/Server.php(319): Game\App\Server->joinGameRoom()
#6 {main}
thrown in @swoole-src/library/core/Database/PDOProxy.php on line 64
[2021-08-09 19:30:23 $29449.0] WARNING check_worker_exit_status: worker#0[pid=29453] abnormal exit, status=255, signal=0
onWorkerError worker_id: 0, worker_pid: 29453, exit_code: 255, signal: 0
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY=true 已开启
BaseModel 实例方法
new BaseModel([
'host' => $config['host'],
'port' => $config['port'],
'database' => $config['database'],
'username' => $config['username'],
'password' => $config['password'],
'charset' => $config['charset'],
'prefix' => $config['prefix'],
// 'unixSocket' => null,
'options' => [
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false,
],
'size' => $config['pool_size'] // 连接池size
]);
swoole 配置
'max_request' => 0, // 设置 worker 进程的最大任务数。【默认值:0 即不会退出进程】
'worker_num' => 1,
'task_worker_num' => 2,
'dispatch_mode' => 5,
'hook_flags' => SWOOLE_HOOK_ALL, // 设置一键协程化 Hook 的函数范围。【默认值:不 hook】
'enable_coroutine' => true,
'task_enable_coroutine' => true, // Task 开启协程
'max_wait_time' => 15, // 设置 Worker 进程收到停止服务通知后最大等待时间【默认值:3】
'reload_async' => true, // 设置异步重启开关, 保证服务重载时,协程或异步任务能正常结束。
我排查了下,发现 quote 方法不能正确的返回,我使用了medoo2.1的 quote处理方法进行替换,发现报错次数有明显减少。
但是以上的报错问题还是存在,我想到的可能是上条查询语句 exec PDO::prepare 实际执行了但没完全返回或者报错,导致后一条语句出现上面问题。
如果接入tcp server,得自已定义包协议,粘包问题用swoole的package_body_offset
,package_length_offset
,package_length_type
等配置自己解决吗,最好引入一下yar
、grpc
等开源协议支持
I cannot seem to find out how to get the request object. Only URI parameters are included in documentation. Would be great if this type of request object is added into the documentation as well.
laravel
用多了
然后用到这个 我竟然连数据库都不知道怎么建立了
所以问下有没有这个想法
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.