You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please answer these questions before submitting your issue.
What did you do? If possible, provide a simple script for reproducing the error.
$server = newSwoole\Websocket\Server('0.0.0.0', 82);
$server->set([
//'worker_num' => (int) swoole_cpu_num(),'task_worker_num' => 3,
'task_enable_coroutine' => true,
]);
$server->on('Task', function ($server, $TaskInfo) {
while (true) {
Swoole\Coroutine::sleep(1);
echo ">>> task ! \n";
foreach ($server->connectionsas$Client) {
echo ">> - -- connn!! \n";
$ClientInfo = $server->getClientInfo($Client);
if ($ClientInfo <> false) {
echo "--2--\n";
print_r($ClientInfo);
}
}
}
});
$server->on('start', function ($server) {
echo "Websocket Server is started at ws://127.0.0.1:9502\n";
$server->task("");
});
$server->on('open', function ($server, $req) {
echo "connection open: {$req->fd}\n";
});
$server->on('message', function ($server, $frame) {
echo "received message: {$frame->data}\n";
$server->push($frame->fd, json_encode(['hello', 'world']));
});
$server->on('close', function ($server, $fd) {
echo "connection close: {$fd}\n";
});
$server->start();
What did you expect to see?
the last v5.0.0.0-dev was working properly, I compiled it manually in centos 7.
but swoole-cli doesn't work anymore,
ineffective in server->connections task,
if I keep the FDs on the table, then
$server->getClientInfo($fd); -> always return false
so getClientInfo from task is not working,
I am closing the manual connection in task,
this code block is not working for this reason.
Data communication between tasks and processes created from this kind of code is extremely problematic and tedious, examples are very few, frankly, I'm struggling, it makes more sense to use structures like nodejs go, swoole should make good optimization in this regard and cancel the use of tables (because the table automatically reserves space from memory at startup and this space becomes unused, a big problem in microservices)
should improve access to variables, that is, if swoole does these messaging operations properly on its own side, the programmer does not have to deal with their mechanisms. (what I mean here is access to global variables and objects from the task and process, access to global variables and objects from the non-local, non-local function in any unit, write from function to global, etc.)
What version of Swoole are you using (show your php --ri swoole)?
swoole-cli 5.1.3 on centos7
What is your machine environment used (show your uname -a & php -v & gcc -v) ?
Linux F.x 3.10.0-1160.118.1.el7.x86_64 #1 SMP Wed Apr 24 16:01:50 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered:
Please answer these questions before submitting your issue.
the last v5.0.0.0-dev was working properly, I compiled it manually in centos 7.
but swoole-cli doesn't work anymore,
ineffective in server->connections task,
if I keep the FDs on the table, then
$server->getClientInfo($fd); -> always return false
so getClientInfo from task is not working,
I am closing the manual connection in task,
this code block is not working for this reason.
Data communication between tasks and processes created from this kind of code is extremely problematic and tedious, examples are very few, frankly, I'm struggling, it makes more sense to use structures like nodejs go, swoole should make good optimization in this regard and cancel the use of tables (because the table automatically reserves space from memory at startup and this space becomes unused, a big problem in microservices)
should improve access to variables, that is, if swoole does these messaging operations properly on its own side, the programmer does not have to deal with their mechanisms. (what I mean here is access to global variables and objects from the task and process, access to global variables and objects from the non-local, non-local function in any unit, write from function to global, etc.)
php --ri swoole
)?swoole-cli 5.1.3 on centos7
uname -a
&php -v
&gcc -v
) ?Linux F.x 3.10.0-1160.118.1.el7.x86_64 #1 SMP Wed Apr 24 16:01:50 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: