session_id is invalid

roczyl

莫名出现一个错误:
session_id 9e61dd40701ad941b20a0011467bf045,PHPSID=9e61dd40701ad941b20a0011467bf045 is invalid in xxx/vendor/workerman/workerman/Protocols/Http/Session.php:426

请问可以怎么排查?

749 2 0
2个回答

admin

1: 先给完整的错误栈
2:一般不用管他

  • roczyl 2023-05-28

    0 /home/wwwroot/www/vendor/workerman/workerman/Protocols/Http/Session.php(144): WorkermanProtocolsHttpSession::checkSessionId()
    1 /home/wwwroot/www/vendor/workerman/workerman/Protocols/Http/Request.php(268): WorkermanProtocolsHttpSession->__construct()
    2 /home/wwwroot/www/app/index/controller/User.php(60): WorkermanProtocolsHttpRequest->session()
    3 [internal function]: appindexcontrollerUser->beforeAction()
    4 /home/wwwroot/www/vendor/webman/action-hook/src/ActionHook.php(28): call_user_func()
    5 /home/wwwroot/www/vendor/workerman/webman-framework/src/App.php(271): WebmanActionHookActionHook->process()
    6 /home/wwwroot/www/vendor/workerman/webman-framework/src/App.php(118): WebmanApp::Webman{closure}()
    7 /home/wwwroot/www/vendor/workerman/workerman/Connection/TcpConnection.php(646): WebmanApp->onMessage()
    8 [internal function]: WorkermanConnectionTcpConnection->baseRead()
    9 /home/wwwroot/www/vendor/workerman/workerman/Events/Event.php(193): EventBase->loop()
    10 /home/wwwroot/www/vendor/workerman/workerman/Worker.php(1629): WorkermanEventsEvent->loop()
    11 /home/wwwroot/www/vendor/workerman/workerman/Worker.php(1423): WorkermanWorker::forkOneWorkerForLinux()
    12 /home/wwwroot/www/vendor/workerman/workerman/Worker.php(1397): WorkermanWorker::forkWorkersForLinux()
    13 /home/wwwroot/www/vendor/workerman/workerman/Worker.php(1779): WorkermanWorker::forkWorkers()
    14 /home/wwwroot/www/vendor/workerman/workerman/Worker.php(1715): WorkermanWorker::monitorWorkersForLinux()
    15 /home/wwwroot/www/vendor/workerman/workerman/Worker.php(562): WorkermanWorker::monitorWorkers()
    16 /home/wwwroot/www/vendor/workerman/webman-framework/src/support/App.php(124): WorkermanWorker::runAll()
    17 /home/wwwroot/www/start.php(4): supportApp::run()
    18 {main}

  • admin 2023-05-29

    你好,根据你的反馈,问题可能出现在appindexcontrollerUser->beforeAction(),你可能擅自调用了session的一些功能,这个是找不到session_file映射导致的,如果你没有代码操作session,可能是你删除了正在运行的/tmp/session_*等文件

  • roczyl 2023-05-29

    我看了下,beforeAction里没有session操作。如果这个是找不到session_file映射导致的,那应该没有影响吧。只是报错倒无所谓。

  • admin 2023-05-30
     public function process(Request $request, callable $next): Response
        {
            if (!self::checkSession($request, ['User', 'Admin'])) {
                return $next($request);
            }
            $request->session = new \Workerman\Protocols\Http\Session($request->header(‘jwt', 'null'));
            $account = $request->session()->get('account', false);
            $uid= $request->session()->get('uid',false);
    
            if (!$account || !$uid) {
                return json(['code' => 401, 'msg' => '身份已失效']);
            }
            $request->account = $account;
            $request->uid =$uid;
            return $next($request);
        }

    你这种情况只有像我这种自定义 middleware的时候,并且还是用了 session机制,前端传过来的jwt作为sessionKey的时候,/tmp/session_* 找不到对应文件的时候才会出现这个问题。这个问题是webman的内置的报错,一般不用理会

  • roczyl 2023-05-30

    明白了,谢谢

latin

session_id is invalid 字面意思,session_id无效。
可能是一些探测程序设置了一些奇怪的session_id。这个错误不影响正常用户,不用管。

  • 暂无评论
年代过于久远,无法发表回答
×
🔝