unable to connect to tcp://0.0.0.0:2346

aassvsv

问题描述

使用命令启动workerman出现问题
php artisan workerman option start --d

程序代码

class Option
{
    protected $serviceName = 'option';

    public function start()
    {
          Worker::$pidFile = '/www/wwwroot/'. env('APP_DOMAIN') .'/public/option.pid';

        $this->startGateWay();
        $this->startBusinessWorker();
        $this->startRegister();
        Worker::runAll();
    }

    private function startBusinessWorker()
    {
        $worker                  = new BusinessWorker();
        $worker->name            = $this->serviceName . 'BusinessWorker';
        $worker->count           = 1;
        $worker->registerAddress = '127.0.0.1:1236';
        $worker->eventHandler    = config("workerman.{$this->serviceName}.eventHandler");
    }

    private function startGateWay()
    {
        $context = array(
            'ssl' => array(
                // 请使用绝对路径
                'local_cert'                 => '/www/server/panel/vhost/cert/'. env('APP_DOMAIN') .'/fullchain.pem', // 也可以是crt文件
                'local_pk'                   => '/www/server/panel/vhost/cert/'. env('APP_DOMAIN') .'/privkey.pem',
                'verify_peer'                => false,
                // 'allow_self_signed' => true, //如果是自签名证书需要开启此选项
            )
        );
        $gateway = new Gateway("websocket://0.0.0.0:2346",$context);
        $gateway->transport = 'ssl';
        $gateway->name                 = $this->serviceName . 'Gateway';
        $gateway->count                = 1;
        $gateway->lanIp                = '127.0.0.1';
        $gateway->startPort            = 2300;
        $gateway->pingInterval         = 30;
        $gateway->pingNotResponseLimit = 1;
        $gateway->pingData             = '{"type":"ping"}';
        $gateway->registerAddress      = '127.0.0.1:1236';
    }

    private function startRegister()
    {
        new Register('text://0.0.0.0:1236');
    }

报错信息

Workerman[workermanoption] stop 
Workerman[workermanoption] not run
Workerman[workermanoption] start in DAEMON mode
stream_socket_server(): unable to connect to tcp://0.0.0.0:2346 (Address already in use) in file /www/wwwroot/xxxxxxx/vendor/workerman/workerman/Worker.php on line 2245

截图报错信息里报错文件相关代码

截图

操作系统及workerman/webman等框架组件具体版本

centos7 + php7.2 +mysql8

469 1 0
1个回答

×
🔝