国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

【已解決】webman/channel組件使用 unix 方式報(bào)錯(cuò)

xiaoming

解決辦法,需要指定協(xié)議

'protocol' => Frame::class

問(wèn)題描述

我在 \Channel\Server::onMessage 方法里面進(jìn)行打印
1 使用端口的方式,正常沒(méi)報(bào)錯(cuò)
plugin.webman.channel.server frame://0.0.0.0:2206

打印如下
string(83) "a:2:{s:4:"type";s:9:"subscribe";s:8:"channels";a:1:{i:0;s:17:"crontab-task-edit";}}"
string(83) "a:2:{s:4:"type";s:9:"subscribe";s:8:"channels";a:1:{i:0;s:17:"crontab-task-edit";}}"

2 使用unix 方式報(bào)錯(cuò)
plugin.webman.channel.server unix:///tmp/channel-1735198572.sock

打印如下 數(shù)據(jù)好像合并成一條
string(174) "Wa:2:{s:4:"type";s:9:"subscribe";s:8:"channels";a:1:{i:0;s:17:"crontab-task-edit";}}Wa:2:{s:4:"type";s:9:"subscribe";s:8:"channels";a:1:{i:0;s:17:"crontab-task-edit";}}"

導(dǎo)致unserialize方法報(bào)錯(cuò)

代碼

1 鏈接

<?php

namespace app\bootstrap;

use support\Log;
use Webman\Bootstrap;
use Webman\Channel\Client;
use Workerman\Worker;

class Channel implements Bootstrap
{

    public static function start(?Worker $worker)
    {
        // 插件進(jìn)程不訂閱
        if (!$worker || $worker->name == 'plugin.webman.channel.server') {
            return;
        }
        try {
            $app_config = config('plugin.webman.channel.app');
            if ($app_config['enable']) {
                $process_config = config('plugin.webman.channel.process');
                $listen         = (string)$process_config['server']['listen'];
                $listen         = trim($listen);
                if (stripos($listen, 'unix://') === 0) {
                    Client::connect($listen);
                } else {
                    [, $ip_info] = explode("http://", $listen, 2);
                    [$ip, $port] = explode(":", trim($ip_info), 2);
                    Client::connect($ip, $port);
                }
            }
        } catch (\Exception $e) {
            Log::error("Bootstrap的Channel " . $e->getMessage());
        }
    }
}

2 訂閱

<?php

namespace app\process;

use Webman\Channel\Client;
use Workerman\Worker;

class CrontabTaskProducer
{
    public function onWorkerStart(Worker $worker)
    {

        Client::on("crontab-task-edit", function ($event_data) {
            var_dump($event_data);
        });

    }
}

3 composer.json

  "require": {
    "php": ">=8.0",
    "workerman/webman-framework": "^1.6.8",
    "monolog/monolog": "^2.0",
    "webman/channel": "^1.0"
  },

操作系統(tǒng)環(huán)境及workerman/webman等具體版本

系統(tǒng) wsl 的ubuntu

Workerman version:4.2.1
PHP version:8.1.26
Event-Loop:\Workerman\Events\Event

609 1 0
1個(gè)回答

walkor 打賞

執(zhí)行composer info 看下 workerman/channel 具體版本

  • xiaoming 2024-12-26

    webman/channel 1.0.1
    workerman/channel 1.2.1

  • walkor 2024-12-26

    config/plugin/webman/channel/process.php 指定下協(xié)議試下

    use Webman\Channel\Server;
    use Workerman\Protocols\Frame;
    
    return [
        'server' => [
            'listen'  => 'unix:///tmp/channel-1735198572.sock',
            'protocol' => Frame::class, // 這里指定協(xié)議
            'handler' => Server::class,
            'reloadable' => false,
            'count' => 1
        ]
    ];
  • xiaoming 2024-12-26

    正常了,謝謝老大

??