在 webman 安装了 redis ,为什么会报错?

andyzu

问题描述

我已经安装了 composer require -W illuminate/redis illuminate/events
截图
之前代码是好着呢,然后重新安装了系统,并重新安装了 laradock ,并把备份的项目,拷贝到新的环境中,就出现了相关的报错信息。
截图

截图

报错信息

{
    "code": 0,
    "msg": "Internal Server Error",
    "data": {
        "domain": "localhost:8989",
        "method": "GET",
        "request_url": "GET /api/v1/code2session?code=0e1qgNFa1mKBUG0inDIa1Uw9rn4qgNFB",
        "timestamp": "2024-02-13 00:59:09",
        "client_ip": "127.0.0.1",
        "request_param": {
            "code": "0e1qgNFa1mKBUG0inDIa1Uw9rn4qgNFB"
        },
        "error_message": "Internal Server Error",
        "error_trace": [
            "#0 /Users/au/Desktop/wwwroot/tyj_api/vendor/illuminate/redis/Connectors/PhpRedisConnector.php(34): Illuminate\\Redis\\Connectors\\PhpRedisConnector->createClient(Array)",
            "#1 /Users/au/Desktop/wwwroot/tyj_api/vendor/illuminate/redis/Connectors/PhpRedisConnector.php(38): Illuminate\\Redis\\Connectors\\PhpRedisConnector->Illuminate\\Redis\\Connectors\\{closure}()",
            "#2 /Users/au/Desktop/wwwroot/tyj_api/vendor/illuminate/redis/RedisManager.php(112): Illuminate\\Redis\\Connectors\\PhpRedisConnector->connect(Array, Array)",
            "#3 /Users/au/Desktop/wwwroot/tyj_api/vendor/illuminate/redis/RedisManager.php(91): Illuminate\\Redis\\RedisManager->resolve('default')",
            "#4 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/webman-framework/src/support/Redis.php(262): Illuminate\\Redis\\RedisManager->connection('default')",
            "#5 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/webman-framework/src/support/Redis.php(281): support\\Redis::connection()",
            "#6 /Users/au/Desktop/wwwroot/tyj_api/app/controller/api/v1/controller/WeChatController.php(63): support\\Redis::__callStatic('select', Array)",
            "#7 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/webman-framework/src/App.php(388): app\\controller\\api\\v1\\controller\\WeChatController::code2session(Object(support\\Request))",
            "#8 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/webman-framework/src/App.php(349): Webman\\App::Webman\\{closure}(Object(support\\Request))",
            "#9 /Users/au/Desktop/wwwroot/tyj_api/vendor/webman/log/src/Middleware.php(96): Webman\\App::Webman\\{closure}(Object(support\\Request))",
            "#10 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/webman-framework/src/App.php(341): Webman\\Log\\Middleware->process(Object(support\\Request), Object(Closure))",
            "#11 /Users/au/Desktop/wwwroot/tyj_api/vendor/webman/cors/src/CORS.php(12): Webman\\App::Webman\\{closure}(Object(support\\Request))",
            "#12 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/webman-framework/src/App.php(341): Webman\\Cors\\CORS->process(Object(support\\Request), Object(Closure))",
            "#13 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/webman-framework/src/App.php(141): Webman\\App::Webman\\{closure}(Object(support\\Request))",
            "#14 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/workerman/Connection/TcpConnection.php(646): Webman\\App->onMessage(Object(Workerman\\Connection\\TcpConnection), Object(support\\Request))",
            "#15 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/workerman/Events/Select.php(311): Workerman\\Connection\\TcpConnection->baseRead(Resource id #306)",
            "#16 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/workerman/Worker.php(1635): Workerman\\Events\\Select->loop()",
            "#17 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/workerman/Worker.php(1426): Workerman\\Worker::forkOneWorkerForLinux(Object(Workerman\\Worker))",
            "#18 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/workerman/Worker.php(1400): Workerman\\Worker::forkWorkersForLinux()",
            "#19 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/workerman/Worker.php(560): Workerman\\Worker::forkWorkers()",
            "#20 /Users/au/Desktop/wwwroot/tyj_api/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\\Worker::runAll()",
            "#21 /Users/au/Desktop/wwwroot/tyj_api/start.php(4): support\\App::run()",
            "#22 {main}"
        ],
        "file": "/Users/au/Desktop/wwwroot/tyj_api/vendor/illuminate/redis/Connectors/PhpRedisConnector.php",
        "line": 79

我运行了 docker-compose exec workspace bash
截图

647 1 0
1个回答

latin

调用栈看是连接redis出问题了,也就是连不上redis。一般是redis地址或端口写错了,也可能是redis没启动或redis没暴露端口给其它应用访问

  • andyzu 2024-02-14

    貌似解决了,我一直以为是 laradcok 里 的 php-cli 只要安装了 redis 就行,其实是需要macOS 本地的 php-cli 也要装 redis 扩展才行。

×
🔝