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

[QUESTION] 升级v2.2后需升级swoole v4.6以后版本 #4058

Closed
ushell opened this issue Sep 14, 2021 · 3 comments
Closed

[QUESTION] 升级v2.2后需升级swoole v4.6以后版本 #4058

ushell opened this issue Sep 14, 2021 · 3 comments
Labels
question Further information is requested

Comments

@ushell
Copy link
Contributor

ushell commented Sep 14, 2021

Before you submit this issue, you has been search all existed issues and search the documentation

  • [] I've been search all existed issues
  • [] I've been read all documentation

Describe your question

版本

  • php: 7.4.8
  • swoole: v4.5.5
  • hyperf: v2.2

升级v2.2版本后,使用config-nacos组件后,启动服务后无法正确获取nacos响应的数据

\Hyperf\Nacos\Provider\ConfigProvider::get() 返回值为空,终端中输出nacos配置信息(http response以stdout形式输出)

    // config_center.php
    //....
    'enable' => (bool) env('CONFIG_CENTER_ENABLE', true),
    'driver' => env('CONFIG_CENTER_DRIVER', 'nacos'),
    'mode' => env('CONFIG_CENTER_MODE', Mode::PROCESS),
    'drivers' => [
        'nacos' => [
            'driver' => Hyperf\ConfigNacos\NacosDriver::class,
            'merge_mode' => Hyperf\ConfigNacos\Constants::CONFIG_MERGE_OVERWRITE,
            'interval' => 3,
            'default_key' => 'sms_config',
            'listener_config' => [
                'sms_config' => [
                    'tenant' => 'foo',
                    'data_id' => 'bar',
                    'group' => 'DEFAULT_GROUP'
                    'type' => 'json',
                ],
            ],

升级swoole v4.6.5版本后问题解决。

// 配置为空导致json:decode抛出异常
#0 /app/vendor/hyperf/config-nacos/src/Client.php(81): Hyperf\Utils\Codec\Json::decode()
#1 /app/vendor/hyperf/config-nacos/src/Client.php(67): Hyperf\ConfigNacos\Client->decode()
#2 /app/vendor/hyperf/config-center/src/AbstractDriver.php(132): Hyperf\ConfigNacos\Client->pull()
#3 /app/vendor/hyperf/config-center/src/AbstractDriver.php(100): Hyperf\ConfigCenter\AbstractDriver->pull()

初步排查是因为guzzlehttp v7.x组件需要高版本swoole

@ushell ushell added the question Further information is requested label Sep 14, 2021
@limingxinleo
Copy link
Member

可以主动安装 guzzle 的 v6.x 版本

也可以自己重写对应的 CoroutineHandler

@ushell
Copy link
Contributor Author

ushell commented Sep 15, 2021

nacos组件升级v2.2后默认使用Guzzlehttp\Guzzle\Handler\CurlHandler

这个handler与swoole的SWOOLE_HOOK_ALL参数存在冲突 swoole/swoole-src#3800

解决方案:
1、升级swoole版本 >=v4.5.8 , v4.5.8修复 swoole/library#74

2、config-nacos组件v2.2配置中提供guzzle参数,使用CoroutineHandler替代CurlHandler

建议v2.2升级文档提示使用CoroutineHandler替代CurlHandler, 或者hyperf-skeleton要求swoole版本v4.6.0以上 @limingxinleo

@limingxinleo
Copy link
Member

肯定不可能要求4.6以上,如果不用curl,其实4.5也能跑。

你这个场景,毕竟只是很小的一部分

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants