swoft-cloud / swoft

🚀 PHP Microservice Full Coroutine Framework
https://swoft.org
Apache License 2.0
5.58k stars 786 forks source link

swoft-2.0.10composer 升级swoft-2.0.11后报这个异常: Swoft\\Rpc\\Client\\Exception\\RpcResponseException) Pool error is Create connection error(Redis::setOption() expects parameter 2 to be string, integer given #1433

Closed MansonWongDev closed 3 years ago

MansonWongDev commented 3 years ago

swoft-2.0.10(未升级之前,两个环境都正常) swoft-2.0.11(composer升级后的代码,其中一个环境异常,另一环境正常)

swoft-2.0.10、swoft-2.0.11都运行正常的环境: ubuntu 18.4 PHP 7.1.33 redis-server 4.0.9 swoole 4.5.5

swoft-2.0.11运行失败的环境是: centos 7 php7.1.33 redis-server 3.2.12 swoole 4.5.2

补充一下,引用了这个组件:composer require devweyes/cache

异常提示:

{
    "code":0,
    "error":"(Swoft\Rpc\Client\Exception\RpcResponseException) Pool error is Create connection error(Redis::setOption() expects parameter 2 to be string, integer given) file(/usr/local/src/project/testredis/vendor/swoft/redis/src/Connector/PhpRedisConnector.php) line (61) file=/usr/local/src/project/testredis/vendor/swoft/connection-pool/src/AbstractPool.php line=265 At /usr/local/src/project/testredis/vendor/swoft/redis/src/Pool.php line 191",
    "file":"At /usr/local/src/project/testredis/vendor/swoft/rpc-client/src/Concern/ServiceTrait.php line 87",
    "trace":"#0 /tmp/WalletInterface_IGNORE_60b888b7ec9d9.php(19): App\Rpc\Lib\WalletInterface_IGNORE_60b888b7ec9d9->__proxyCall('App\\Rpc\\Lib\\Wal...', 'getBalance', Array)
#1 /usr/local/src/project/testredis/app/Http/Controller/RpcController.php(45): App\Rpc\Lib\WalletInterface_IGNORE_60b888b7ec9d9->getBalance(12)
#2 /usr/local/src/project/testredis/vendor/swoft/stdlib/src/Helper/PhpHelper.php(64): App\Http\Controller\RpcController->rpcTestRedis()
#3 /usr/local/src/project/testredis/vendor/swoft/http-server/src/Middleware/DefaultMiddleware.php(83): Swoft\Stdlib\Helper\PhpHelper::call(Array)
#4 /usr/local/src/project/testredis/vendor/swoft/http-server/src/RequestHandler.php(80): Swoft\Http\Server\Middleware\DefaultMiddleware->process(Object(Swoft\Http\Message\Request), Object(Swoft\Http\Server\RequestHandler))
#5 /usr/local/src/project/testredis/vendor/swoft/http-server/src/Middleware/ValidatorMiddleware.php(58): Swoft\Http\Server\RequestHandler->handle(Object(Swoft\Http\Message\Request))
#6 /usr/local/src/project/testredis/vendor/swoft/http-server/src/RequestHandler.php(80): Swoft\Http\Server\Middleware\ValidatorMiddleware->process(Object(Swoft\Http\Message\Request), Object(Swoft\Http\Server\RequestHandler))
#7 /usr/local/src/project/testredis/vendor/swoft/http-server/src/Middleware/UserMiddleware.php(62): Swoft\Http\Server\RequestHandler->handle(Object(Swoft\Http\Message\Request))
#8 /usr/local/src/project/testredis/vendor/swoft/http-server/src/RequestHandler.php(80): Swoft\Http\Server\Middleware\UserMiddleware->process(Object(Swoft\Http\Message\Request), Object(Swoft\Http\Server\RequestHandler))
#9 /usr/local/src/project/testredis/vendor/swoft/view/src/Middleware/ViewMiddleware.php(50): Swoft\Http\Server\RequestHandler->handle(Object(Swoft\Http\Message\Request))
#10 /usr/local/src/project/testredis/vendor/swoft/http-server/src/RequestHandler.php(80): Swoft\View\Middleware\ViewMiddleware->process(Object(Swoft\Http\Message\Request), Object(Swoft\Http\Server\RequestHandler))
#11 /usr/local/src/project/testredis/vendor/swoft/session/src/SessionMiddleware.php(74): Swoft\Http\Server\RequestHandler->handle(Object(Swoft\Http\Message\Request))
#12 /usr/local/src/project/testredis/vendor/swoft/http-server/src/RequestHandler.php(80): Swoft\Http\Session\SessionMiddleware->process(Object(Swoft\Http\Message\Request), Object(Swoft\Http\Server\RequestHandler))
#13 /usr/local/src/project/testredis/app/Http/Middleware/FavIconMiddleware.php(46): Swoft\Http\Server\RequestHandler->handle(Object(Swoft\Http\Message\Request))
#14 /usr/local/src/project/testredis/vendor/swoft/http-server/src/RequestHandler.php(80): App\Http\Middleware\FavIconMiddleware->process(Object(Swoft\Http\Message\Request), Object(Swoft\Http\Server\RequestHandler))
#15 /usr/local/src/project/testredis/vendor/swoft/http-server/src/HttpDispatcher.php(87): Swoft\Http\Server\RequestHandler->handle(Object(Swoft\Http\Message\Request))
#16 /usr/local/src/project/testredis/vendor/swoft/http-server/src/Swoole/RequestListener.php(47): Swoft\Http\Server\HttpDispatcher->dispatch(Object(Swoft\Http\Message\Request), Object(Swoft\Http\Message\Response))
#17 {main}"
}
inhere commented 3 years ago

是不是 redis server 版本问题。

v2.0.11 PhpRedisConnector.php) line 61 强制了 int

 if (!empty($option['serializer'])) {
       $client->setOption(Redis::OPT_SERIALIZER, (int)$option['serializer']);
 }
MansonWongDev commented 3 years ago

是不是 redis server 版本问题。

v2.0.11 PhpRedisConnector.php) line 61 强制了 int

 if (!empty($option['serializer'])) {
       $client->setOption(Redis::OPT_SERIALIZER, (int)$option['serializer']);
 }

是,跑在redis-server 4.0.9是正常的,跑在redis-server 3.2.12就异常,不过如果是redis环境问题,swoft 2.0.11对redis server 最低版本要求或者设置是否应该告知一下用户好点,或者swoft能否兼容进去

MansonWongDev commented 3 years ago

composer require devweyes/cache

是不是 redis server 版本问题。 v2.0.11 PhpRedisConnector.php) line 61 强制了 int

 if (!empty($option['serializer'])) {
       $client->setOption(Redis::OPT_SERIALIZER, (int)$option['serializer']);
 }

是,跑在redis-server 4.0.9是正常的,跑在redis-server 3.2.12就异常,不过如果是redis环境问题,swoft 2.0.11对redis server 最低版本要求或者设置是否应该告知一下用户好点,或者swoft能否兼容进去

或者说是这个轮子的问题:composer require devweyes/cache

costa92 commented 3 years ago

是 phpredis 版本的问题的,需求升级,

MansonWongDev commented 3 years ago

是 phpredis 版本的问题的,需求升级,

还真是这个版本问题!我把redis-server版本3.X升级6.X了还是不行, php的redis模块 也是3.x的,升级为5.3就问题解决了,感谢提醒

MansonWongDev commented 3 years ago

问题解决,感谢大佬们~

MansonWongDev commented 3 years ago

问题解决,感谢大佬们~

costa92 commented 3 years ago

申请到 5.3 还有一个问题,cache redis set 时间参数设置了默认为null 但是 phpredis set 时间参数为 正 int ,所以设置set 函数的时候一定要注意。不然会出现exception