用定时器不断执行 Gateway::getAllGroupIdList();刚开始有用,几分钟后只能得到空数组。Gateway::getAllClientIdCount()得到0
有没有办法销毁Gateway,重新连接?
尝试:定时器每3秒重复运行:
\GatewayClient\Context::clear();
Gateway::$registerAddress = '127.0.0.1:9138';
$aaa = Gateway::getAllUidList();
在php7.4.8没问题。在php8.0.3报错:
thrown
at vendor/workerman/gatewayclient/Gateway.php:450
446▕ $uid_map = array();
447▕ foreach ($data as $local_ip => $buffer_array) {
448▕ foreach ($buffer_array as $local_port => $items) {
449▕ //$items = ['connection_id'=>['uid'=>x, 'group'=>[x,x..], 'session'=>[..]], 'client_id'=>[..], ..];
➜ 450▕ foreach ($items as $connection_id => $info) {
451▕ if (!empty($info['uid'])) {
452▕ $uid_map[$info['uid']] = $info['uid'];
453▕ }
454▕ }
Whoops\Exception\ErrorException
Uncaught ErrorException: foreach() argument must be of type array|object, bool given in /var/www/html/vendor/workerman/gatewayclient/Gateway.php:450
Stack trace:
#0 /var/www/html/vendor/workerman/gatewayclient/Gateway.php(450): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'foreach() argum...', '/var/www/html/v...', 450)
#1 /var/www/html/app/Http/Controllers/Index/Reload.php(2121): GatewayClient\Gateway::getAllUidList()
php4.8不会这样。 php8开启jit会这样
现阶段,还是用php7.4,比较稳妥
有的包需要8.0才能运行,没办法
找到了原因,这个方法,在php8中运行多次后会出错:
GatewayClient\GatewayProtocol的encode方法:
{
但是不知道是哪里错了,需要重复运行多次之后才会出错
不是这个给原因