Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis的消息发布与订阅没有反应 #1391

Open
webphplove opened this issue Nov 6, 2020 · 2 comments
Open

redis的消息发布与订阅没有反应 #1391

webphplove opened this issue Nov 6, 2020 · 2 comments
Assignees
Labels
swoft: db Issues for swoft db component

Comments

@webphplove
Copy link

Q A
Bug report? yes
Feature request? yes
Swoft version 2.0.10
Swoole version 4.5.1
PHP version PHP 7.3.21
Runtime environment Ubuntu

Describe the bug
A clear and concise description of what the bug is.

我开启了一个进程处理redis的发布订阅,代码如下:

<?php
namespace App\Process;

use Swoft\Bean\Annotation\Mapping\Bean;
use Swoft\Db\Exception\DbException;
use Swoft\Log\Helper\CLog;
use Swoft\Process\Process;
use Swoft\Process\UserProcess;
use Swoft\Redis\Redis;

/**
 * Class QueueSubscribeProcess
 * @package App\Process
 * @Bean()
 */
class QueueSubscribeProcess extends UserProcess
{

    /**
     * @param Process $process
     *
     * @throws DbException
     */
    public function run(Process $process): void
    {
        while (true) {

            ini_set('default_socket_timeout', -1); //不超时

            // 订阅 2 个频道
            Redis::subscribe(['test'], function ($redis, $pattern, $chan, $msg){
                echo "Pattern: $pattern\n";
                echo "Channel: $chan\n";
                echo "Payload: $msg\n";
            });
            Coroutine::sleep(3);
        }
    }
}

我使用redis发布消息,这个订阅没有反应。
我也通过swoft程序发布消息,而程序的订阅和redis客户端订阅频道,也没有任何反应

@github-actions github-actions bot added the swoft: db Issues for swoft db component label Nov 6, 2020
@sakuraovq
Copy link
Member

cli 测试有反应的 看看 使用是否正确 框架没有做封装 使用的 redis 扩展

@webphplove
Copy link
Author

我用swoole 的redis有反应, 而用swoft 一定反应都没有

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
swoft: db Issues for swoft db component
Projects
None yet
Development

No branches or pull requests

2 participants