webman多协议配置发送问题不确定是不是Bug

tongnian

问题描述

需要用到两个协议,ws和客户端联系,tcp和机器联系
webman框架集成了gatewayworker
截图
截图

程序代码或配置

<?php

use Webman\GatewayWorker\Gateway;
use Webman\GatewayWorker\BusinessWorker;
use Webman\GatewayWorker\Register;

return [
    'gateway' => [
        'handler'     => Gateway::class,
        'listen'      => 'tcp://0.0.0.0:8950',
        'count'       => cpu_count(),
        'reloadable'  => false,
        'constructor' => ['config' => [
            'lanIp'           => '127.0.0.1',
            'startPort'       => 2400,
            'pingInterval'    => 10,
            'pingData'        => \app\services\BallMagicService::COMMAND_HEALTH_CHECK, //心跳,
            'registerAddress' => '127.0.0.1:1236',
            'onConnect'       => function(){},
            'pingNotResponseLimit' => 1,
        ]]
    ],
    'worker' => [
        'handler'     => BusinessWorker::class,
        'count'       => cpu_count()*2,
        'constructor' => ['config' => [
            'eventHandler'    => plugin\webman\gateway\Events::class,
            'name'            => 'TcpBusinessWorker',
            'registerAddress' => '127.0.0.1:1236',
        ]]
    ],
    //ws
    'gateway_ws' => [
        'handler'     => Gateway::class,
        'listen'      => 'websocket://0.0.0.0:5252',
        'count'       => cpu_count(),
        'reloadable'  => false,
        'constructor' => ['config' => [
            'lanIp'           => '127.0.0.1',
            'startPort'       => 2300,
            'pingInterval'    => 10,
            'pingData'        => '123456', //心跳,
            'registerAddress' => '127.0.0.1:1236',
            'onConnect'       => function(){},
            'pingNotResponseLimit' => 1,
        ]]
    ],
    'worker_ws' => [
        'handler'     => BusinessWorker::class,
        'count'       => cpu_count()*2,
        'constructor' => ['config' => [
            'eventHandler'    => plugin\webman\gateway\WebSocketEvents::class,
            'name'            => 'WsBusinessWorker',
            'registerAddress' => '127.0.0.1:1236',
        ]]
    ],

    'register' => [
        'handler'     => Register::class,
        'listen'      => 'text://127.0.0.1:1236',
        'count'       => 1, // Must be 1
        'constructor' => []
    ],
];

重现问题的步骤

机器发送的tcp数据在wsEvent里了。两个协议数据互相串。一下子正常,一下子又出问题

120 1 0
1个回答

你这样配置就是多协议数据互通的,不是bug

如果你不要两个协议互相通讯,也就是部署两个gatewayWorker服务,就把config/process.php里的GatewayWorker相关配置都拷贝一份,端口全部加100

  • tongnian 3天前

    谢谢老大的回复,我两个协议需要互相通讯。详细看了一遍文档,最后用了event文件,按照gateway_port做了区分

×
🔝