walkor / gatewayclient Goto Github PK
View Code? Open in Web Editor NEWSdk For GatewayWorker
License: MIT License
Sdk For GatewayWorker
License: MIT License
当前系统
windows11 + wsl Ubuntu 20.04
开发环境
Workerman version:4.1.14 PHP version:8.2.13 laravel 8.7.5
Win IP地址 10.10.30.230
Ubuntu IP地址 172.18.232.186
win启用网络转发:netsh interface portproxy add v4tov4 listenport=2346 listenaddress=10.10.30.230 connectport=2346 connectaddress=172.18.232.186
ErrorException: stream_socket_server(): Unable to connect to tcp://10.10.30.230:2300 (Cannot assign requested address) in /var/www/html/vendor/workerman/workerman/Worker.php:2360
worker[Gateway:155] exit with status 64000
请问上述lanIp registerAddress变量 以及 Register 对象的参数应该填写什么,win下WebSocket connection正常?
This is exception message :
Allowed memory size of 134217728 bytes exhausted (tried to allocate 659456 bytes) {"exception":"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0): Allowed memory size of 134217728 bytes exhausted (tried to allocate 659456 bytes) at /var/workspace/server1/vendor/workerman/gatewayclient/Gateway.php:1305)
Is any suggest ?
建议把 self::$registerAddress 改成 static::$registerAddress
这样我新建一个类,继承Gateway后, 就可以覆盖里面的配置了
Event可以通过onClose感知链接断开,但是业务逻辑都在mvc框架中,请问清理逻辑应该写在哪里?
我在 php 框架里使用 GatewayClient 连接到 GatewayWorker 的时候得到这个错误:
Register auth timeout (xx.xx.xx.xx). See http://wiki.workerman.net/Error4 for detail
查看 wiki 里面说:
有程序向Register服务发起了socket链接,然而Register服务不允许其它程序链接。
注意:客户端应该链接Gateway端口,不应该链接Register端口。
我有几个问题:
谢谢。
GatewayWorker 使用的是3.0.12版本
PHP 5.6.31
安装时报如下错误:
composer require workerman/gatewayclient
Zend Guard Loader requires Zend Engine API version 220090626.
The Zend Engine API version 220131226 which is installed, is newer.
Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Guard Loader.
Using version ^3.0 for workerman/gatewayclient
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- paragonie/random_compat v9.99.99 requires php ^7 -> your PHP version (5.6.31) does not satisfy that requirement.
- paragonie/random_compat v9.99.99 requires php ^7 -> your PHP version (5.6.31) does not satisfy that requirement.
- paragonie/random_compat v9.99.99 requires php ^7 -> your PHP version (5.6.31) does not satisfy that requirement.
- Installation request for paragonie/random_compat (locked at v9.99.99) -> satisfiable by paragonie/random_compat[v9.99.99].
Installation failed, reverting ./composer.json to its original content.
Hi, My friend:
this is my question. I used this client in my project. there are two workman-server in my project .
I need to send the same message to those server.So, how can i do it?
执行代码
Gateway::$registerAddress = "{$host}:{$port}";
echo "register=", Gateway::$registerAddress, PHP_EOL;
while(true) {
var_dump([
'Gateway::getAllUidCount()' => Gateway::getAllUidCount(),
'getClientIdByUid' => Gateway::getClientIdByUid('123'),
]);
sleep(1);
}
执行的日志
[centos@ip-172-20-4-112 GatewayWorker]$ php -f ./bin/demo.php
register=127.0.0.1:1239
array(2) {
["Gateway::getAllUidCount()"]=>
int(5)
["getClientIdByUid"]=>
array(1) {
[0]=>
string(20) "000000000beb00000320"
}
}
array(2) {
["Gateway::getAllUidCount()"]=>
int(5)
["getClientIdByUid"]=>
array(1) {
[0]=>
string(20) "000000000beb00000320"
}
}
array(2) {
["Gateway::getAllUidCount()"]=>
int(5)
["getClientIdByUid"]=>
array(1) {
[0]=>
string(20) "000000000beb00000320"
}
}
array(2) {
["Gateway::getAllUidCount()"]=>
int(5)
["getClientIdByUid"]=>
array(1) {
[0]=>
string(20) "000000000beb00000320"
}
}
PHP Fatal error: Uncaught Exception: Gateway::getAllGatewayAddressesFromRegister() with registerAddress:"127.0.0.1:1239" return array (
) in /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php:1314
Stack trace:
#0 /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php(726): GatewayClient\Gateway::getAllGatewayAddressesFromRegister()
#1 /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php(701): GatewayClient\Gateway::getAllGatewayAddress()
#2 /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php(650): GatewayClient\Gateway::getBufferFromAllGateway()
#3 /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php(445): GatewayClient\Gateway::select()
#4 /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php(466): GatewayClient\Gateway::getAllUidList()
#5 /www/wwwroot/GatewayWorker/bin/demo.php(26): GatewayClient\Gateway::getAllUidCount()
#6 {main}
thrown in /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php on line 1314
Fatal error: Uncaught Exception: Gateway::getAllGatewayAddressesFromRegister() with registerAddress:"127.0.0.1:1239" return array (
) in /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php:1314
Stack trace:
#0 /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php(726): GatewayClient\Gateway::getAllGatewayAddressesFromRegister()
#1 /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php(701): GatewayClient\Gateway::getAllGatewayAddress()
#2 /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php(650): GatewayClient\Gateway::getBufferFromAllGateway()
#3 /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php(445): GatewayClient\Gateway::select()
#4 /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php(466): GatewayClient\Gateway::getAllUidList()
#5 /www/wwwroot/GatewayWorker/bin/demo.php(26): GatewayClient\Gateway::getAllUidCount()
#6 {main}
thrown in /www/wwwroot/GatewayWorker/vendor/workerman/gatewayclient/Gateway.php on line 1314
有时候返回的数据是正常的, 有时候报错
Fatal error: in ../../Gateway.php on line 1286
Gateway.php当无法连接SETCKET时,代码会报错,没有做异常处理。
我composer更新了以为是阿里的缓存没更新 搞了半天你这版本号没改
报错信息
我也不清楚为什么会出现这种情况
PHP Warning: pack(): Type H: illegal hex digit - in /path/Gateway.class.php on line 941
Warning: pack(): Type H: illegal hex digit - in /path/Gateway.class.php on line 941
PHP Warning: pack(): Type H: illegal hex digit - in /path/Gateway.class.php on line 941
Warning: pack(): Type H: illegal hex digit - in /path/Gateway.class.php on line 941
PHP Warning: pack(): Type H: illegal hex digit - in /path/Gateway.class.php on line 941
Warning: pack(): Type H: illegal hex digit - in /path/Gateway.class.php on line 941
PHP Warning: pack(): Type H: illegal hex digit - in /path/Gateway.class.php on line 941
Warning: pack(): Type H: illegal hex digit - in /path/Gateway.class.php on line 941
PHP Warning: pack(): Type H: illegal hex digit - in /path/Gateway.class.php on line 941
Warning: pack(): Type H: illegal hex digit - in /path/Gateway.class.php on line 941
PHP Warning: stream_socket_client(): unable to connect to tcp://0.22.80.20:32788 (Invalid argument) in /path/Gateway.class.php on line 668
Warning: stream_socket_client(): unable to connect to tcp://0.22.80.20:32788 (Invalid argument) in /path/Gateway.class.php on line 668
版本:
workerman/gateway-worker v3.0.7
workerman/workerman v3.5.1
php 7.2.4
升级测试3.0.0升级到3.0.9使用Gateway::bindUid()不能绑定uid,返回null
php版本:8.1.17
clinet版本:v3.0.14
代码
$roomIds = [ 2, 3, 4 ];
Gateway::joinGroup(xxxxxxxxxx, $roomIds);
报错
local.ERROR: strlen(): Argument #1 ($string) must be of type string, array given {"exception":"[object] (TypeError(code: 0): strlen(): Argument #1 ($string) must be of type string, array given at D:\laragon\www\da-back\vendor\workerman\gatewayclient\Gateway.php:1579)
[stacktrace]
1579行代码
$ext_len = strlen($data['ext_data']);
断点$data输出
array (
'cmd' => 20,
'local_ip' => 0,
'local_port' => 0,
'client_ip' => 0,
'client_port' => 0,
'connection_id' => 487,
'flag' => 1,
'gateway_port' => 0,
'ext_data' =>
array (
0 => 2,
1 => 3,
2 => 4,
),
'body' => '',
)
在框架中通过GatewayClient获取群组内uid数组时GatewayWorker报错
框架报错:
Invalid argument supplied for foreach()
GatewayWorker报错:
Exception: gateway inner pack err cmd=25 in C:\Users\GLJSHY\Desktop\GatewayWorker\vendor\workerman\gateway-worker-for-win\src\Gateway.php:797
Stack trace:
#0 [internal function]: GatewayWorker\Gateway->onWorkerMessage(Object(Workerman\Connection\TcpConnection), Array)
#1 C:\Users\GLJSHY\Desktop\GatewayWorker\vendor\workerman\workerman-for-win\Connection\TcpConnection.php(629): call_user_func(Array, Object(Workerman\Connection\TcpConnection), Array)
#2 [internal function]: Workerman\Connection\TcpConnection->baseRead(Resource id #49)
#3 C:\Users\GLJSHY\Desktop\GatewayWorker\vendor\workerman\workerman-for-win\Events\Select.php(286): call_user_func_array(Array, Array)
#4 C:\Users\GLJSHY\Desktop\GatewayWorker\vendor\workerman\workerman-for-win\Worker.php(856): Workerman\Events\Select->loop()
#5 C:\Users\GLJSHY\Desktop\GatewayWorker\vendor\workerman\gateway-worker-for-win\src\Gateway.php(279): Workerman\Worker->run()
#6 C:\Users\GLJSHY\Desktop\GatewayWorker\vendor\workerman\workerman-for-win\Worker.php(473): GatewayWorker\Gateway->run()
#7 C:\Users\GLJSHY\Desktop\GatewayWorker\vendor\workerman\workerman-for-win\Worker.php(382): Workerman\Worker::runAllWorkers()
#8 C:\Users\GLJSHY\Desktop\GatewayWorker\Applications\Chat\start_gateway.php(63): Workerman\Worker::runAll()
#9 {main}
process C:\Users\GLJSHY\Desktop\GatewayWorker\Applications\Chat\start_gateway.php terminated and try to restart
使用Gateway::getAllGroupIdList(void)出现相同报错
/**
* gateway 实例
*
* @var object
*/
protected static $businessWorker = null;
/**
* 注册中心地址
*
* @var string
*/
public static $registerAddress = '127.0.0.1:1236';
/**
* 秘钥
* @var string
*/
public static $secretKey = '';
/**
* 链接超时时间
* @var int
*/
public static $connectTimeout = 3;
请问以上配置中的secretKey是取什么秘钥?是不是gateway配置中的keypath?
In Gateway.php:
const CMD_GET_CLINET_SESSIONS_BY_GROUP = 23; <== wrong
const CMD_GET_CLIENT_SESSIONS_BY_GROUP = 23; <== correct
看例子随便一个client设置一下$registerAddress,就可以给所有客户端发消息了,那样就避免不了一些“非法”client“乱”发消息。
如果在其它客户端做消息签名校验之类好像又不太好,有没办法在服务端设置校验?只有校验通过的client消息才能发给其它客户端?
[2] ErrorException in Gateway.php line 739
stream_socket_client():
第739行的内容是
$client= stream_socket_client("tcp://$address", $errno, $errmsg, self::$connectTimeout, $flag);
下面是Stack信息
# Call Stack
in Gateway.php line 739 at Error::appError(2, 'stream_socket_client...', 'D:\www\susenew\exten...', 739, ['address' => '0.0.0.0:4002', 'gateway_buffer' => '...', 'flag' => 4, ...]) at stream_socket_client('tcp://0.0.0.0:4002', 10049, '...', 3, 4) in Gateway.php line 739 at Gateway::sendBufferToGateway('0.0.0.0:4002', '...') in Gateway.php line 766 at Gateway::sendToAllGateway(['cmd' => 6, 'local_ip' => 0, 'local_port' => 0, ...]) in Gateway.php line 107 at Gateway::sendToAll('{"type":"say","user_...') in Push.php line 18 at Push->index() at ReflectionMethod->invokeArgs(object(Push), []) in App.php line 224 at App::invokeMethod([object(Push), 'index'], []) in App.php line 389 at App::module(['api', 'push', 'index'], ['app_namespace' => 'app', 'app_debug' => true, 'app_trace' => false, ...], null) in App.php line 130 at App::run() in start.php line 18 at require('D:\www\susenew\think...') in index.php line 17
你好,
Gateway::$registerAddress = '127.0.0.1:1236';
执行Gateway::sendToAll('7777');
报错:
Can not connect to tcp://127.0.0.1:1236 Connection refused
Workerman[start.php] status ----------------------------------------------GLOBAL STATUS---------------------------------------------------- Workerman version:3.5.15 PHP version:7.0.32-0ubuntu0.16.04.1 start time:2018-11-22 23:34:57 run 0 days 0 hours load average: 1.73, 1, 1 event-loop:\Workerman\Events\Select 4 workers 11 processes worker_name exit_status exit_count ChatBusinessWorker 64000 3 ChatGateway 0 0 Register 0 0 WebServer 0 0 ----------------------------------------------PROCESS STATUS--------------------------------------------------- pid memory listening worker_name connections send_fail timers total_request qps status 6806 4M none ChatBusinessWorker 5 0 0 5 0 [idle] 6808 4M none ChatBusinessWorker 5 0 0 5 0 [idle] 6810 2M websocket://0.0.0.0:7272 ChatGateway 5 0 1 7 0 [idle] 6811 2M websocket://0.0.0.0:7272 ChatGateway 5 0 1 7 0 [idle] 6812 2M websocket://0.0.0.0:7272 ChatGateway 7 0 1 21 0 [idle] 6813 2M websocket://0.0.0.0:7272 ChatGateway 6 0 1 14 0 [idle] 6814 2M text://0.0.0.0:1236 Register 8 0 0 11 0 [idle] 6815 2M http://0.0.0.0:55151 WebServer 0 0 0 0 0 [idle] 6816 2M http://0.0.0.0:55151 WebServer 0 0 0 0 0 [idle] 6817 4M none ChatBusinessWorker 5 0 0 6 0 [idle] 6864 4M none ChatBusinessWorker 5 0 0 11 0 [idle]
在一次http接口请求中执行两次sendToUid会提示
Bad request for Register service. Request info(IP:127.0.0.1, Request Buffer:xxxxxxxxxxxx). See http://doc2.workerman.net/register-auth-timeout.html
但实际上都成功发送到设备了
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.