Giter Site home page Giter Site logo

gatewayclient's Issues

Can not connect to tcp://127.0.0.1:1236 Connection refused

你好,
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]

为什么注册的时候必须用text协议,但是连接却代码里写死了用tcp协议呢?
screenshot from 2018-11-22 23-49-44

在thinkphp5中使用3.0版本出现一下问题

[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

constant spell wrong

In Gateway.php:

const CMD_GET_CLINET_SESSIONS_BY_GROUP = 23; <== wrong

const CMD_GET_CLIENT_SESSIONS_BY_GROUP = 23; <== correct

Windows+WSL开发环境

当前系统
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

image

请问上述lanIp registerAddress变量 以及 Register 对象的参数应该填写什么,win下WebSocket connection正常?

使用client循环到注册中心去取数据有时候会报错

执行代码

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

有时候返回的数据是正常的, 有时候报错

GatewayClient使用Gateway::getUidListByGroup报错

在框架中通过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)出现相同报错

strlen() expects parameter 1 to be string, array given

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' => '',
)

权限验证怎么做?

看例子随便一个client设置一下$registerAddress,就可以给所有客户端发消息了,那样就避免不了一些“非法”client“乱”发消息。

如果在其它客户端做消息签名校验之类好像又不太好,有没办法在服务端设置校验?只有校验通过的client消息才能发给其它客户端?

Register auth timeout

我在 php 框架里使用 GatewayClient 连接到 GatewayWorker 的时候得到这个错误:

Register auth timeout (xx.xx.xx.xx). See http://wiki.workerman.net/Error4 for detail

查看 wiki 里面说:
有程序向Register服务发起了socket链接,然而Register服务不允许其它程序链接。
注意:客户端应该链接Gateway端口,不应该链接Register端口。

我有几个问题:

  • 这里的客户端指的是 GatewayClient 吧,GatewayClient 里有个参数 $registerAddress,这个不是指连接到 Register 服务吗?这个是否矛盾?
  • 会不会对服务产生影响?实际上我仍然能够通过 GatewayClient 给 app 发消息。
  • 有什么办法避免这个错误?

谢谢。

关于Gateway类中的secretKey 说明

/**
* 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?

在一次http接口请求中执行多次sendToUid报错

在一次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
但实际上都成功发送到设备了

PHP Warning: pack(): Type H: illegal hex digit

报错信息

我也不清楚为什么会出现这种情况

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

GatewayClient::closeClient

GatewayClient::closeClient is not working in Distributed Deployment
I cannot close a client connect to server #2 from server #1

Also Please implement closeUid

Best regards

memory leak problem

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 ?

GatewayWorker 使用的是3.0.12版本 PHP 5.6.31 安装时报如下错误: composer require workerman/gatewayclient

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.